Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
-
source HEAD `c894d97781b5` (13.2.0-alpha);
-
Can result in hang or crash
Description
With `--rpl-semi-sync-master-enabled=ON`, `clean_up()` stops the semisync master and then shuts the
plugin subsystem down:
- `sql/mysqld.cc:5818` — semi-sync master initialization during startup.
- `sql/mysqld.cc:5936` — the pre-close abort path (also `sql/mysqld.cc:2535`) that reaches
`clean_up()` before the normal `close_connections()` shutdown sequence. - `sql/mysqld.cc:2181` — `semi_sync_master_deinit()`.
- `sql/mysqld.cc:2183` — `plugin_shutdown()` immediately afterwards.
- `sql/mysqld.cc:1969` — `close_connections()`, which is what normally stops the ack receiver
earlier and masks the race.
The ack-receiver thread's `run()` destroys its THD at the end, and the THD destructor takes
`LOCK_plugin` (`sql/sql_plugin.cc:3464`, `sql/sql_class.cc:1841/1937`). After the MDEV-32551 rework,
`stop()` returns as soon as `m_status == ST_DOWN` while `delete thd` is still pending
(`sql/semisync_master_ack_receiver.cc:383-390`, `sql/semisync_master.cc:1562-1566`). `clean_up()` then
calls `plugin_shutdown()`, which locks and destroys `LOCK_plugin` and releases the plugin hash
(`sql/sql_plugin.cc:2239-2240`) while the ack THD may still be running its destructor — the THD can
lock a destroyed mutex and access freed plugin state.
-
- Expected result
`stop()` must not report `ST_DOWN` before the ack THD has actually been destroyed (or
`semi_sync_master_deinit()` must explicitly join the ack thread), so that `plugin_shutdown()` cannot
destroy `LOCK_plugin` while a THD destructor still needs it.