Bug #58108 Add handlerton::wait_setup hook
Submitted: 10 Nov 2010 11:17 Modified: 1 Dec 2022 10:14
Reporter: Magnus Blåudd Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.5.7-rc OS:Any
Assigned to: CPU Architecture:Any
Tags: SEAGULL

[10 Nov 2010 11:17] Magnus Blåudd
Description:
Add a new handlerton hook wait_setup to be called
1) after handlerton::init but just before  the place where MySQL starts to accept connections.
2) In slave SQL thread before to run it's applier loop.

This is required by ndbcluster to initialize some global structures/tables used for replication and inter mysqld communication. Threads would otherwise be using a readonly NDB database and writes would fail.

How to repeat:
.

Suggested fix:
5.5$ bzr diff
=== modified file 'sql/handler.h'
--- sql/handler.h	2010-10-06 14:34:28 +0000
+++ sql/handler.h	2010-11-10 11:16:16 +0000
@@ -788,6 +788,8 @@ struct handlerton
                                  const char *name);
    uint32 license; /* Flag for Engine License */
    void *data; /* Location for engines to keep personal structures */
+
+  bool (*wait_setup)(handlerton *hton);
 };

=== modified file 'sql/mysqld.cc'
--- sql/mysqld.cc	2010-10-08 14:52:39 +0000
+++ sql/mysqld.cc	2010-11-10 11:08:53 +0000
@@ -4566,6 +4566,8 @@ int mysqld_main(int argc, char **argv)
   mysql_cond_signal(&COND_server_started);
   mysql_mutex_unlock(&LOCK_server_started);
 
+  ha_wait_setup();
+
 #if defined(_WIN32) || defined(HAVE_SMEM)
   handle_connections_methods();
 #else

=== modified file 'sql/slave.cc'
--- sql/slave.cc	2010-10-09 10:18:16 +0000
+++ sql/slave.cc	2010-11-10 11:11:15 +0000
@@ -3224,6 +3224,8 @@ pthread_handler_t handle_slave_sql(void 
 #endif
   DBUG_ASSERT(rli->sql_thd == thd);
 
+  ha_wait_setup();
+
   DBUG_PRINT("master_info",("log_file_name: %s  position: %s",
                             rli->group_master_log_name,
                             llstr(rli->group_master_log_pos,llbuff)));
[10 Nov 2010 11:26] Magnus Blåudd
Generic fix for Bug#46955
[10 Nov 2010 11:31] Magnus Blåudd
libmysqld/lib_sql.cc also need to call the hooks

see http://lists.mysql.com/commits/88358
[10 Nov 2010 12:17] Davi Arnaut
Can't the engine lock itself and unlock once it is ready?
[11 Nov 2010 15:30] Magnus Blåudd
The engine starts up as readonly until the inital setup has been performed.
[1 Dec 2022 10:14] Magnus Blåudd
Posted by developer:
 
This was implemented by "WL#6821: GCS Replication: Interfaces for DBMS lifecycle events" which added `Server_state_observer`. Closing.