Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Won't Do
-
None
-
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)
Attachments
Issue Links
- relates to
-
MDEV-5864 Reduce usage of LOCK_open: TABLE_SHARE::tdc.free_tables
- Closed
-
MDEV-4702 Reduce usage of LOCK_open
- Closed
-
MDEV-4956 Reduce usage of LOCK_open: TABLE_SHARE::tdc.used_tables
- Closed
-
MDEV-5388 Reduce usage of LOCK_open: unused_tables
- Closed
-
MDEV-5403 Reduce usage of LOCK_open: tc_count
- Closed
-
MDEV-5597 Reduce usage of LOCK_open: LOCK_flush
- Closed
-
MDEV-5964 main.mdev-504 unveils assertion failure in TABLE_SHARE::visit_subgraph
- Closed