Bug #19209 Test 'rpl_openssl' hangs on Windows
Submitted: 20 Apr 2006 1:42 Modified: 16 Feb 2007 20:29
Reporter: Kent Boortz Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.0.20a,5.1 OS:Microsoft Windows (Windows 2003)
Assigned to: Magnus Blåudd CPU Architecture:Any

[20 Apr 2006 1:42] Kent Boortz
Description:
Test 'rpl_openssl' hangs on Windows, the "master.log"
ends with

 060420  3:53:54       8 Connect     Access denied for user 'replssl'@'localhost' (using password: NO)
 060420  3:53:55       2 Query       show master status
                       9 Connect     replssl@localhost on
                       9 Query       SELECT UNIX_TIMESTAMP()
                       9 Query       SHOW VARIABLES LIKE 'SERVER_ID'
                       9 Query       SHOW SLAVE HOSTS
                       9 Binlog Dump Log: 'master-bin.000001'  Pos: 310

The "slave.log" ends with

060420  3:53:55       1 Query       change master to master_ssl=1 , master_ssl_ca ='e:/build/mysql-pro-gpl-5.0.20a-build/mysql-pro-gpl-5.0.20a-win32/mysql-test/std_data/cacert.pem', master_ssl_cert='e:/build/mysql-pro-gpl-5.0.20a-build/mysql-pro-gpl-5.0.20a-win32/mysql-test/std_data/client-cert.pem', master_ssl_key='e:/build/mysql-pro-gpl-5.0.20a-build/mysql-pro-gpl-5.0.20a-win32/mysql-test/std_data/client-key.pem'                      
                      1 Query       start slave
                      1 Query       select master_pos_wait('master-bin.000001', 398)
                      7 Connect Out replssl@127.0.0.1:9306
                      8 Query       insert into t1 values (1)
                      1 Query       select * from t1
                      1 Query       show slave status
                      1 Query       stop slave

and "slave.err" with

060420  3:53:51 [ERROR] Slave I/O thread: error connecting to master 'replssl@127.0.0.1:9306': Error: 'Access denied for user 'replssl'@'localhost' (using password: NO)'  errno: 1045  retry-time: 1  retries: 10
060420  3:53:55 [Note] Slave I/O thread killed while connecting to master
060420  3:53:55 [Note] Slave I/O thread exiting, read up to log 'master-bin.000001', position 310
060420  3:53:55 [Note] Error reading relay log event: slave SQL thread was killed
060420  3:53:55 [Note] Slave SQL thread initialized, starting replication in log 'master-bin.000001' at position 310, relay log 'e:\build\mysql-pro-gpl-5.0.20a-build\mysql-pro-gpl-5.0.20a-win32\mysql-test\var\log\slave-relay-bin.000001' position: 4
060420  3:53:55 [Note] Slave I/O thread: connected to master 'replssl@127.0.0.1:9306',  replication started in log 'master-bin.000001' at position 310

How to repeat:
Run test case on Windows
[12 May 2006 9:24] Valeriy Kravchuk
We have 5.0.21 released now. Is this problem solved already?
[12 Jun 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[3 Jul 2006 8: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/8633
[3 Jul 2006 10:37] 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/8640
[15 Dec 2006 12:23] 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/17044

ChangeSet@1.2351, 2006-12-15 13:23:45+01:00, msvensson@neptunus.(none) +1 -0
  Bug#19209 Test 'rpl_openssl' hangs on Windows
   - Remove check not to run on windows.
[25 Jan 2007 15:09] Magnus Blåudd
This is caused by the same problem as "Bug#25203 Mysql crashes when mysql_kill() is executed in a connection using SSL".

It will only occur on platforms where we have defined SIGNAL_WITH_VIO_CLOSE and the probability for it incrases when using SSL since the time for closing a vio with SSL is longer. The SIGNAL_WITH_VIO_CLOSE will cause the thread that are killing another thread to actively close the vio of the thread to be killed. Since no mutex is used during this operation it's highly likely that the killing thread AND the to be killed thread both frees the SSL and vio memory.
[25 Jan 2007 15:16] Magnus Blåudd
All threads calling 'THD::awake' are holding the "thd::LOCK_delete" mutex when performing the close but that is not used from 'close_connection' where 'vio_close' is called a second time.
[25 Jan 2007 15:31] Magnus Blåudd
Hmm, since the thread to be killed don't wake up until it's socket has been closed  it safe to modify it's variables. Thus care should be taken to set all freed and to be freed memory to NULL before closing the socket.

That will do it. ;)
[26 Jan 2007 10:34] 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/18839

ChangeSet@1.2393, 2007-01-26 11:34:56+01:00, msvensson@shellback.(none) +1 -0
  Bug#19209 Test 'rpl_openssl' hangs on Windows
   - Remove the hack to not run it on windows
[29 Jan 2007 15:55] 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/18958

ChangeSet@1.2392, 2007-01-29 16:54:40+01:00, msvensson@neptunus.(none) +95 -0
  Import latest version of yaSSL
   - Replace SawTooth copyright header with MySQL's
   - Bug#19209 Test 'rpl_openssl' hangs on Windows
   - Spurious "2013 Connection to server lost" errors fixed
     yaSSL doesn't close socket anymore, that is left to the application
[14 Feb 2007 15:06] Chad MILLER
Available in 5.0.36, and 5.1.16-beta.
[16 Feb 2007 20:29] Paul Dubois
Noted in 5.0.36, 5.1.16 changelogs.

Use of already freed memory caused SSL connections to hang forever.