[MDEV-5492] Reduce usage of LOCK_open: TABLE::in_use Created: 2013-12-27  Updated: 2016-06-28  Resolved: 2016-06-28

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Sergey Vojtovich Assignee: Sergey Vojtovich
Resolution: Won't Do Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-5864 Reduce usage of LOCK_open: TABLE_SHAR... Closed
relates to MDEV-4702 Reduce usage of LOCK_open Closed
relates to MDEV-4956 Reduce usage of LOCK_open: TABLE_SHAR... Closed
relates to MDEV-5388 Reduce usage of LOCK_open: unused_tables Closed
relates to MDEV-5403 Reduce usage of LOCK_open: tc_count Closed
relates to MDEV-5597 Reduce usage of LOCK_open: LOCK_flush Closed
relates to MDEV-5964 main.mdev-504 unveils assertion failu... Closed
Sprint: 10.2.1-3, 10.2.1-4, 10.2.1-5

 Description   

tc_acquire_table and tc_release_table are critical sections of table cache. Among other things, they update TABLE::in_use:
tc_acquire_table - table->in_use= current_thd
tc_release_table - table->in_use= 0

Normally table->in_use is only accessed/modified by thread that owns this table instance, which means access to this variable doesn't really need to be synchronized.

There are a few exception though when foreign threads may read this variable:

  • TABLE_SHARE::visit_subgraph() (MDL deadlock detector): called after marking table(s) old and purging unused table instances, thus tc_acquire_table() must never change in_use (because there is nothing to acquire); tc_release_table() must be fixed not to change in_use while table is in all_tables list. Otherwise no synchronization needed.
  • kill_delayed_threads_for_table(): mostly same as for TABLE_SHARE::visit_subgraph().
  • list_open_tables(): no synchronization needed, unsafe access is acceptable.
  • print_cached_tables() (debug only): synchronization needed.
  • check_unused() (debug only): remove this function, it was supposed to check unused_tables, which was eliminated by MDEV-5388.
  • tdc_remove_table() (debug only): no extra synchronization needed, protected by exclusive MDL.

There are a few options how we can synchronize access to this variable:

  • mutex (can be complex, MDL deadlock detecter needs recursive lock)
  • rwlock
  • atomic spinlock (requires much less memory than mutex/rwlock)


 Comments   
Comment by Sergey Vojtovich [ 2013-12-27 ]

Sergei, please review patch for this task.

Comment by Sergey Vojtovich [ 2014-02-13 ]

Pushed to 10.0.9, revno: 4004, revision-id: svoj@mariadb.org-20140213064410-c4a589vn86iphxri

Comment by Sergey Vojtovich [ 2016-05-13 ]

serg, please review top 3 patches in bb-10.2-mdev5492.

Comment by Sergey Vojtovich [ 2016-06-28 ]

Should not be needed with multi-instance table cache.

Generated at Thu Feb 08 07:04:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.