Bug #37869 mysqld stopped reacting to SIGINT when run with --gdb
Submitted: 4 Jul 2008 12:14 Modified: 19 Feb 2009 19:33
Reporter: Alexander Nozdrin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:6.0.6-alpha, 6.0 bzr OS:Linux
Assigned to: Michael Widenius CPU Architecture:Any
Tags: regression

[4 Jul 2008 12:14] Alexander Nozdrin
Description:
When the server (mysqld) run with '--gdb' option, it used to react to SIGINT.
This is not the case anymore.

See also: Bug#21567

How to repeat:
$ ./mysqld --gdb
080704 16:10:58  InnoDB: Started; log sequence number 0 46409
080704 16:10:58 [Note] Event Scheduler: Loaded 0 events
080704 16:10:58 [Note] ./mysqld: ready for connections.
Version: '6.0.6-alpha-debug'  socket: '/home/alik/Documents/MySQL/var/6.0-rt-wl4300/mysqld.socket'  port: 3307  Source distribution

<Ctrl-C> -- nothing happens

<Ctrl-/>
080704 16:11:02 [Note] Got signal 3 to shutdown mysqld
080704 16:11:02 [Note] ./mysqld: Normal shutdown
080704 16:11:02 [Note] Event Scheduler: Purging the queue. 0 events
080704 16:11:02  InnoDB: Starting shutdown...
080704 16:11:04  InnoDB: Shutdown completed; log sequence number 0 46409
080704 16:11:05 [Note] ./mysqld: Shutdown complete
$
[23 Jul 2008 18:32] Sveta Smirnova
Thank you for the report.

Verified as described. Only version 6.0 is affected.
[18 Aug 2008 2:53] Tatiana Azundris Nuernberg
I presume ^/ should be ^\, SIGQUIT?

That aside, ^C works when actually run *within GDB*, so it could be argued it's less of a bug, and more of a nuisance. Looking though.
[19 Aug 2008 2:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51902

2776 Tatiana A. Nurnberg	2008-08-19
      Bug#37869: mysqld stopped reacting to SIGINT when run with --gdb
      
      Control-C was misdirected to a handler that ignored it.
[25 Nov 2008 12:11] Michael Widenius
Not sure if this is a bug or not.

The main object with --gdb is that one can always use ^C to break mysqld when running withing gdb. Before my change this didn't work in all contex/systems as SIGINT was not handled at all by mysqld.

The change I did was to fix this, but also to ensure that --gdb should work in identically if thr_kill_signal is set to SIGINT.
(The fix was needed for some system on which I was testing Maria and needed to get ^C to work in gdb)

I would like to suggest that we should always handle SIGINT and thr_kill_signal identically becasue thr_kill_signal may be set to SIGINT on some systems. (This is what my change did)

The proposed patch does not handle the case where thr_kill_signal is set to SIGINT. It also causes --gdb to not work withing gdb for cases where the signal mask for the mysqld process masks SIGINT.

A better fix is to abort mysqld withing end_thread_signal if mysqld is started interatively.

Another option is to leave the code as it was before and just document that --gdb only have an effect withing --gdb.
[25 Nov 2008 12:24] Michael Widenius
Digged around this a bit more:

As we are using sigprocmask(SIG_SETMASK) the mask for the process doesn't affect mysqld.

However mysqld --gdb before didn't do a clean shutdown of mysqld, which is something we shouldn't support that easily. If we want to have ^C work when using mysqld outside of gdb, we have to handle the signal properly and do a full clean shutdown. The old behavior can too easily lead to crashed tables.
[2 Dec 2008 20:00] Michael Widenius
Fixed in MySQL-5.1-maria tree; Will be merged to 6.0 shortly
[15 Dec 2008 10:08] Bugs System
Pushed into 6.0.9-alpha  (revid:monty@mysql.com-20081202200029-qnq93ymde9t1q449) (version source revid:guilhem@mysql.com-20081213204800-0nubni3t4ihn4hv9) (pib:5)
[19 Feb 2009 19:33] Paul DuBois
Noted in 6.0.9 changelog.