Bug #86271 The delayed plugin initialization thread is left running when it is not needed
Submitted: 10 May 2017 14:42 Modified: 15 Sep 2017 12:21
Reporter: Pedro Gomes Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Group Replication Severity:S3 (Non-critical)
Version:8.0.2 OS:Any
Assigned to: CPU Architecture:Any

[10 May 2017 14:42] Pedro Gomes
Description:
When GR is installed during server start but start on boot is not set, the class

Delayed_initialization_thread

is instantiated and a new thread is started.

This thread is left running even if there is no purpose for it.
Two aspects of this bug:

1) The thread was supposed to receive  signal when the server is ready
This signal however depends on the flag

wait_on_engine_initialization

and this flag is only set to true if the plugin is starting on boot.

2) This thread was used to create the GR user and start the plugin.
Since we no longer create users we can omit the instantiation and start of this class when start on boot is false.

This would solve 1.

I'm not sure though if this class can still be needed if the user passes to a starting server a set of queries for execution.
If in these queries we start group replication, does the start process still depends on the delayed thread? 
This must be checked. 

How to repeat:
In the gr_capture test add a 2 minute sleep when the servers are running and executing queries

Run 

./mtr  --retry=0 --timer  --vardir=/dev/shm/delay_bug_test   --suite=group_replication group_replication.gr_capture  --testcase-timeout=1

See in the stack trace that a delayed thread is left running waiting for the server to start.

Suggested fix:
Create and use this class only when the plugin is starting on boot if possible (see the last part of problem statement)
[15 Sep 2017 12:21] David Moss
Posted by developer:
 
Thank you for your feedback, this has been fixed in upcoming versions and the following was added to the 5.7.20 / 8.0.3 changelog:
The delayed initialization mechanism used for server starts has been improved. Now, it only blocks connections until the server is in read mode.
[18 Sep 2017 9:46] David Moss
Posted by developer:
 
Note mistake in last message: change log entry was added to 8.0.4 not 8.0.3.