drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
Locking

Functions

static void drizzled::print_lock_error (int error, const char *)
static void drizzled::reset_lock_data_and_free (DrizzleLock *&lock)
static bool drizzled::locked_named_table (TableList *table_list)
static bool drizzled::must_wait (bool is_not_commit)
DrizzleLock * drizzled::Session::lockTables (Table **tables, uint32_t count, uint32_t flags)
int drizzled::Session::lock_external (Table **tables, uint32_t count)
void drizzled::Session::unlockTables (DrizzleLock *sql_lock)
void drizzled::Session::unlockSomeTables (Table **table, uint32_t count)
void drizzled::Session::unlockReadTables (DrizzleLock *sql_lock)
void drizzled::Session::removeLock (Table *table)
void drizzled::Session::abortLock (Table *table)
bool drizzled::Session::abortLockForThread (Table *table)
int drizzled::Session::unlock_external (Table **table, uint32_t count)
DrizzleLock * drizzled::Session::get_lock_data (Table **table_ptr, uint32_t count, bool should_lock, Table **write_lock_used)
int drizzled::Session::lock_table_name (TableList *table_list)
void drizzled::TableList::unlock_table_name ()
bool drizzled::Session::wait_for_locked_table_names (TableList *table_list)
bool drizzled::Session::lock_table_names (TableList *table_list)
bool drizzled::Session::lock_table_names_exclusively (TableList *table_list)
void drizzled::TableList::unlock_table_names (TableList *last_table=NULL)
bool drizzled::Session::lockGlobalReadLock ()
void drizzled::Session::unlockGlobalReadLock ()
bool drizzled::Session::wait_if_global_read_lock (bool abort_on_refresh, bool is_not_commit)
void drizzled::Session::startWaitingGlobalReadLock ()
bool drizzled::Session::makeGlobalReadLockBlockCommit ()
void drizzled::locking::broadcast_refresh (void)

Variables

static drizzled::error_t drizzled::thr_lock_errno_to_mysql []
volatile uint32_t drizzled::global_read_lock =0
volatile uint32_t drizzled::global_read_lock_blocks_commit =0
static volatile uint32_t drizzled::protect_against_global_read_lock =0
static volatile uint32_t drizzled::waiting_for_read_lock =0

Detailed Description

Function Documentation

◆ abortLock()

void drizzled::Session::abortLock ( Table * table)

Abort all other threads waiting to get lock in table.

Definition at line 431 of file global.cc.

◆ abortLockForThread()

bool drizzled::Session::abortLockForThread ( Table * table)

Abort one thread / table combination.

Parameters
sessionThread handler
tableTable that should be removed from lock queue
Return values
0Table was not locked by another thread
1Table was locked by at least one other thread

Definition at line 458 of file global.cc.

◆ broadcast_refresh()

void drizzled::locking::broadcast_refresh ( void )

Broadcast COND_refresh and COND_global_read_lock.

Due to a bug in a threading library it could happen that a signal did not reach its target. A condition for this was that the same condition variable was used with different mutexes in pthread_cond_wait(). Some time ago we changed table::Cache::mutex() to LOCK_global_read_lock in global read lock handling. So COND_refresh was used with table::Cache::mutex() and LOCK_global_read_lock.

We did now also change from COND_refresh to COND_global_read_lock in global read lock handling. But now it is necessary to signal both conditions at the same time.

Note
When signalling COND_global_read_lock within the global read lock handling, it is not necessary to also signal COND_refresh.

Definition at line 1115 of file global.cc.

◆ get_lock_data()

DrizzleLock * drizzled::Session::get_lock_data ( Table ** table_ptr,
uint32_t count,
bool should_lock,
Table ** write_lock_used )
private

Get lock structures from table structs and initialize locks.

Parameters
sessionThread handler
table_ptrPointer to tables that should be locks
should_lockOne of:
  • false : If we should send TL_IGNORE to store lock
  • true : Store lock info in Table
write_lock_usedStore pointer to last table with WRITE_ALLOW_WRITE

Definition at line 509 of file global.cc.

◆ lock_external()

int drizzled::Session::lock_external ( Table ** tables,
uint32_t count )
private

Definition at line 286 of file global.cc.

◆ lock_table_name()

int drizzled::Session::lock_table_name ( TableList * table_list)

Put a not open table with an old refresh version in the table cache.

Parameters
table_listLock first table in this list
check_in_useDo we need to check if table already in use by us
Note
One must have a lock on table::Cache::mutex()!
Warning
If you are going to update the table, you should use lock_and_wait_for_table_name(removed) instead of this function as this works together with 'FLUSH TABLES WITH READ LOCK'
Note
This will force any other threads that uses the table to release it as soon as possible.
Returns
< 0 error
== 0 table locked

0 table locked, but someone is using it

Definition at line 621 of file global.cc.

◆ lock_table_names()

bool drizzled::Session::lock_table_names ( TableList * table_list)

Lock all tables in list with a name lock.

REQUIREMENTS

  • One must have a lock on table::Cache::mutex() when calling this
Parameters
table_listNames of tables to lock
Return values
0ok
1Fatal error (end of memory ?)

Definition at line 716 of file global.cc.

◆ lock_table_names_exclusively()

bool drizzled::Session::lock_table_names_exclusively ( TableList * table_list)

Unlock all tables in list with a name lock.

Parameters
table_listNames of tables to lock.
Note
This function needs to be protected by table::Cache::mutex(). If we're under LOCK TABLES, this function does not work as advertised. Namely, it does not exclude other threads from using this table and does not put an exclusive name lock on this table into the table cache.
See also
lock_table_names
unlock_table_names
Return values
TRUEAn error occured.
FALSEName lock successfully acquired.

Definition at line 759 of file global.cc.

◆ locked_named_table()

bool drizzled::locked_named_table ( TableList * table_list)
static

Definition at line 661 of file global.cc.

◆ lockGlobalReadLock()

bool drizzled::Session::lockGlobalReadLock ( )

Definition at line 917 of file global.cc.

◆ lockTables()

DrizzleLock * drizzled::Session::lockTables ( Table ** tables,
uint32_t count,
uint32_t flags )

Definition at line 174 of file global.cc.

◆ makeGlobalReadLockBlockCommit()

bool drizzled::Session::makeGlobalReadLockBlockCommit ( )

Definition at line 1060 of file global.cc.

◆ must_wait()

bool drizzled::must_wait ( bool is_not_commit)
inlinestatic

Definition at line 976 of file global.cc.

◆ print_lock_error()

void drizzled::print_lock_error ( int error,
const char * table )
static

Definition at line 808 of file global.cc.

◆ removeLock()

void drizzled::Session::removeLock ( Table * table)

Try to find the table in the list of locked tables. In case of success, unlock the table and remove it from this list.

Note
This function has a legacy side effect: the table is unlocked even if it is not found in the locked list. It's not clear if this side effect is intentional or still desirable. It might lead to unmatched calls to unlock_external(). Moreover, a discrepancy can be left unnoticed by the storage engine, because in unlock_external() we call handler::external_lock(F_UNLCK) only if table->current_lock is not F_UNLCK.
Parameters
sessionthread context
lockedlist of locked tables
tablethe table to unlock
always_unlockspecify explicitly if the legacy side effect is desired.

Definition at line 423 of file global.cc.

◆ reset_lock_data_and_free()

void drizzled::reset_lock_data_and_free ( DrizzleLock *& lock)
static

Reset lock type in lock data and free.

Parameters
mysql_lockLock structures to reset.
Note
After a locking error we want to quit the locking of the table(s). The test case in the bug report for Bug #18544 has the following cases: 1. Locking error in lock_external() due to InnoDB timeout.
  1. Locking error in get_lock_data() due to missing write permission.
  2. Locking error in wait_if_global_read_lock() due to lock conflict.
In all these cases we have already set the lock type into the lock data of the open table(s). If the table(s) are in the open table cache, they could be reused with the non-zero lock type set. This could lead to ignoring a different lock type with the next lock.
Clear the lock type of all lock data. This ensures that the next lock request will set its lock type properly.

Definition at line 167 of file global.cc.

◆ startWaitingGlobalReadLock()

void drizzled::Session::startWaitingGlobalReadLock ( )

Definition at line 1045 of file global.cc.

◆ unlock_external()

int drizzled::Session::unlock_external ( Table ** table,
uint32_t count )
private

Unlock a set of external.

Definition at line 476 of file global.cc.

◆ unlock_table_name()

void drizzled::TableList::unlock_table_name ( )

Definition at line 651 of file global.cc.

◆ unlock_table_names()

void drizzled::TableList::unlock_table_names ( TableList * last_table = NULL)

Unlock all tables in list with a name lock.

Parameters
table_listNames of tables to unlock
last_tableDon't unlock any tables after this one. (default 0, which will unlock all tables)
Note
One must have a lock on table::Cache::mutex() when calling this.
This function will broadcast refresh signals to inform other threads that the name locks are removed.
Return values
0ok
1Fatal error (end of memory ?)

Definition at line 798 of file global.cc.

◆ unlockGlobalReadLock()

void drizzled::Session::unlockGlobalReadLock ( void )

Definition at line 954 of file global.cc.

◆ unlockReadTables()

void drizzled::Session::unlockReadTables ( DrizzleLock * sql_lock)

unlock all tables locked for read.

Definition at line 348 of file global.cc.

◆ unlockSomeTables()

void drizzled::Session::unlockSomeTables ( Table ** table,
uint32_t count )

Unlock some of the tables locked by lockTables.

This will work even if get_lock_data fails (next unlock will free all)

Definition at line 334 of file global.cc.

◆ unlockTables()

void drizzled::Session::unlockTables ( DrizzleLock * sql_lock)

Definition at line 319 of file global.cc.

◆ wait_for_locked_table_names()

bool drizzled::Session::wait_for_locked_table_names ( TableList * table_list)
private

Definition at line 680 of file global.cc.

◆ wait_if_global_read_lock()

bool drizzled::Session::wait_if_global_read_lock ( bool abort_on_refresh,
bool is_not_commit )

Definition at line 983 of file global.cc.

Variable Documentation

◆ global_read_lock

uint32_t volatile drizzled::global_read_lock =0

Definition at line 912 of file global.cc.

◆ global_read_lock_blocks_commit

volatile uint32_t drizzled::global_read_lock_blocks_commit =0

Definition at line 913 of file global.cc.

◆ protect_against_global_read_lock

volatile uint32_t drizzled::protect_against_global_read_lock =0
static

Definition at line 914 of file global.cc.

◆ thr_lock_errno_to_mysql

drizzled::error_t drizzled::thr_lock_errno_to_mysql[]
static
Initial value:
=
{ EE_OK, EE_ERROR_FIRST, ER_LOCK_WAIT_TIMEOUT, ER_LOCK_DEADLOCK }

Definition at line 143 of file global.cc.

◆ waiting_for_read_lock

volatile uint32_t drizzled::waiting_for_read_lock =0
static

Definition at line 915 of file global.cc.