WL#5033: Call unlock_external() before thr_multi_unlock()
Affects: Server-5.4
—
Status: Complete
In 6.0, as the Marie engine committed in ha_maria::external_unlock(F_UNLCK), it
was possible to have this scenario in time order:
thread 1 (INSERT) thread 2 (SELECT on same table)
thr_lock()
write_row()
thr_lock() -- waits on thread 1
thr_multi_unlock()
thr_lock() finishes
reads just inserted row
crash.
Recovery deletes the uncommitted row. So thread2 has seen a row which was never
committed and does not exist. Dirty read, non-isolation... bad.
To fix this, unlock_external() is called before thr_multi_unlock() in 6.0. This
way, the commit in Maria happens before the table is accessible to the other
thread's SELECT, which is proper isolation.
This was implemented by
revision-id: sp1r-serg@janus.mylan-20070704202758-57919
timestamp: Wed 2007-07-04 22:27:58 +0200
message:
in mysql_unlock_tables(), do thr_unlock() AFTER external_unlock().
it means, {update,restore}_status() should be called in external_lock,
not in thr_unlock. Only affects storage engines that support
TL_WRITE_CONCURRENT.
This is present in 6.0 and Azalea (but not in 5.1).
There is nothing to document in the manual, it's not a user-visible change.
Copyright (c) 2000, 2025, Oracle Corporation and/or its affiliates. All rights reserved.