Merge lp:~sergei.glushchenko/percona-server/ST30462-bug925343-5.5 into lp:percona-server/5.5
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Alexey Kopytov | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 495 | ||||
Proposed branch: | lp:~sergei.glushchenko/percona-server/ST30462-bug925343-5.5 | ||||
Merge into: | lp:percona-server/5.5 | ||||
Diff against target: |
66 lines (+7/-16) 1 file modified
Percona-Server/client/mysql.cc (+7/-16) |
||||
To merge this branch: | bzr merge lp:~sergei.glushchenko/percona-server/ST30462-bug925343-5.5 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexey Kopytov (community) | Approve | ||
Stewart Smith (community) | Approve | ||
Review via email: mp+156861@code.launchpad.net |
Description of the change
Bug 925343: mysql client aborts connection on terminal resize.
Fix for upstream bug #26780 "patch to add auto vertical output
option to the cli" introduced SIGWINCH handling by mysql cli.
This leads to EINTR to be returned by read call on socket.
On most systems there is a possibility for read call
to be automatically restarted if SA_RESTART flag is set for
the signal. Hovewer this is not the case, as read timeout on
socket has been set. Linux manual page for signal(7) tells that
there is no chance for read to be restarted if timeout has
been set on socket. It doesn't matter whether SA_RESTART has
been used for signal or not.
So the only portable solution would be to block signal for the
time when client communicates with server. This however would
require a lot of carefull code reading to spot all the point
of such communication in source code and wrap them with
block/unblock signal.
That is why option to completely disable SIGWINCH handling
has been choosen. The only purpose of SIGWINCH handler was to
determine new width of terminal window. The only place where
this width is used is to print output from the server.
Handling of SIGWINCH has been replaced with explicit invocation
of ioctl to get terminal width just before print of result set
is started.
http://
Sergei,
I don't understand this fix. It is correct that a socket I/O operation is not automatically restarted if socket timeouts are used and when the operation is interrupted by a signal handler. However, we don't use SA_RESTART, so the network code does not rely on that behavior. Otherwise the server might crash on signals as well.
Furthermore, the fix removes the mysql.cc signal handler, but the comments suggest that handler will be called from the _readline_ handler. It is also described in the readline docs:
"Readline contains an internal signal handler that is installed for a number of signals (SIGINT, SIGQUIT, SIGTERM, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU). When one of these signals is received, the signal handler will reset the terminal attributes to those that were in effect before readline() was called, reset the signal handling to what it was before readline() was called, and resend the signal to the calling application.
"
So:
- what was really the reason of the crash. Revision comments say nothing on that.
- even if we remove mysql's own signal handler for SIGWINCH, there are other signal handlers installed by both mysql.cc and readline. Following the explanation form the revision comments, those may also result in a crash?