[MDEV-20638] Remove the deadcode from srv_master_thread() and srv_active_wake_master_thread_low() Created: 2019-09-20  Updated: 2020-08-19  Resolved: 2020-07-23

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2.15, 10.3.7
Fix Version/s: 10.2.33, 10.3.24

Type: Bug Priority: Major
Reporter: Thirunarayanan Balathandayuthapani Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 0
Labels: None

Attachments: File MDEV-20638-10.2-e40ed0e881690ed072c28c0f4080a3cfb83e5d73v1.patch    
Issue Links:
Problem/Incident
causes MDEV-23475 InnoDB performance regression for wri... Closed
is caused by MDEV-16125 Shutdown crash when innodb_force_reco... Closed

 Description   

Deadcode is present in srv_master_thread() and srv_active_wake_master_thread_low().
srv_master_thread() doesn't even wait for any event. So there is no need to wake the
master thread with setting the event.

This issue caused by mdev-16125:

commit fe95cb2e40d73adbbe88efa0e7f48c055ccd042f
Author: Thirunarayanan Balathandayuthapani <thiru@mariadb.com>
Date:   Wed May 9 19:00:30 2018 +0530
 
    MDEV-16125  Shutdown crash when innodb_force_recovery >= 2
 



 Comments   
Comment by Thirunarayanan Balathandayuthapani [ 2020-04-13 ]

Attaching the patch to remove the deadcode MDEV-20638-10.2-e40ed0e881690ed072c28c0f4080a3cfb83e5d73v1.patch

Comment by Marko Mäkelä [ 2020-04-15 ]

This looks good to me, but I think that we can remove even more code:

  • Remove srv_wake_master_thread() and invoke srv_inc_activity_count() instead.
  • Simplify srv_master_thread further. Because srv_shutdown_state cannot change back to SRV_SHUTDOWN_NONE while the thread exists, the switch can be removed.
  • Make parameter of srv_check_activity() in/out, removing the need of most calls to srv_get_activity_count().
  • Do we need SRV_MASTER_SLOT and SRV_MASTER at all? What is the srv_reserve_slot(SRV_MASTER) good for?

Idea for srv_master_thread simplification:

	while (srv_shutdown_state == SRV_SHUTDOWN_NONE) {
	}
	ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS || srv_shutdown_state == SRV_SHUTDOWN_CLEANUP);
	os_thread_exit();
}

Comment by Thirunarayanan Balathandayuthapani [ 2020-07-09 ]

Fixed all the review comments and patch is in bb-10.2-thiru. We need SRV_MASTER_SLOT, SRV_MASTER & srv_reserve_slot(SRV_MASTER) to make sure
that master thread exits before assigning SRV_SHUTDOWN_FLUSH_PHASE

Comment by Marko Mäkelä [ 2020-07-13 ]

Thank you for the update. I sent some comments. I think that any potentially functional changes must be documented in the commit message.

Comment by Marko Mäkelä [ 2020-07-22 ]

This looks OK, but you forgot to remove INNOBASE_WAKE_INTERVAL from extra/mariabackup/xtrabackup.cc and storage/innobase/handler/ha_innodb.cc. I can also spot some inadvertent changes to white space. The commit message should mention that srv_master_thread() does not need to call srv_resume_thread() and therefore there is no need to wake up the thread.

Generated at Thu Feb 08 09:01:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.