[MDEV-5289] master server starts slave parallel threads Created: 2013-11-14 Updated: 2015-03-11 Resolved: 2015-03-11 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Replication |
| Affects Version/s: | 10.0.5 |
| Fix Version/s: | 10.0.18 |
| Type: | Bug | Priority: | Major |
| Reporter: | Giuseppe Maxia | Assignee: | Kristian Nielsen |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | master, parallelslave, replication | ||
| Environment: |
install master/slave replication |
||
| Description |
|
When you run this command in a slave
However, if you run the same command in a master, the statement is accepted, and the thread started.
|
| Comments |
| Comment by Elena Stepanova [ 2013-11-14 ] |
|
Is it wrong? There is no slave running on the master (I assume there is none, right?), so why would it throw ER_SLAVE_MUST_STOP? Maybe I misunderstand the nature of the problem, could you please elaborate on it? |
| Comment by Giuseppe Maxia [ 2013-11-14 ] |
|
It is wrong, because slave threads are started in a server that is NOT configured as a slave. I have no idea what these threads do in the master, but surely I would not want additional threads running in a production server. The right behavior should be do nothing. Then if I run 'start slave', I should get an error that the server is not configured as a slave, and all is well. |
| Comment by Elena Stepanova [ 2013-11-14 ] |
|
I see, yes, it makes sense that the value should be configurable, but the actual thread start should only happen when the server starts serving as a slave. |
| Comment by Kristian Nielsen [ 2013-11-14 ] |
|
I do not think this is worth it, it just causes needless complexity. Those are just background threads. They are waiting for work, if no work It is just like the InnoDB background threads. If you enable InnoDB you get |
| Comment by Kristian Nielsen [ 2013-11-14 ] |
|
BTW, the MySQL 5.6 variable is quite different if I understand correctly. In MariaDB, the threads just form a thread pool, shared among any configured slaves. They do not do anything except sit ready, waiting for work from slave SQL threads. In the future, one could imagine a more advanced thread pool management, eg. that |
| Comment by Giuseppe Maxia [ 2013-11-14 ] |
|
I agree that MySQL 5.6 behavior is quite different. |
| Comment by Kristian Nielsen [ 2013-11-14 ] |
|
Right, so the pool of threads could magically spring into life upon the first CHANGE MASTER statement, and be teared down when the last slave is removed by RESET SLAVE ALL. But I do not have bandwidth to work on that kind of stuff... |
| Comment by Kristian Nielsen [ 2013-11-17 ] |
|
I changed my mind a bit, would be nice to not have the threads started unnecessarily, even if they are not harmful as such. So re-opening. |
| Comment by Kristian Nielsen [ 2014-06-10 ] |
|
Idea for how to implement this in a way that works with the current code without introducing extra locking overhead: 1. Do not start the worker threads in the pool at server start. 2. In start_slave_threads(), first startup the worker threads, if we did not already. 3. At the end of handle_slave_sql(), if we are shutting down the last SQL driver thread, shut down the pool of worker threads also. And do the similar thing for the slave background thread also. This has to be started briefly during server startup (to load mysql.gtid_slave_pos), but we can at that point stop it again, and then start and stop it along with the worker threads in the pool. |
| Comment by Kristian Nielsen [ 2015-03-11 ] |
|
Pushed to 10.0.18: http://lists.askmonty.org/pipermail/commits/2015-March/007562.html With this patch, parallel replication worker threads are not spawned until Thanks, Giuseppe, for reporting this! |