Drizzled Public API Documentation

Locking

Namespaces

namespace  drizzled::locking

Functions

static void drizzled::print_lock_error (int error, const char *)
static void drizzled::reset_lock_data_and_free (DrizzleLock **mysql_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 ()

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

Function Documentation

void drizzled::Session::abortLock ( Table table) [inherited]

Abort all other threads waiting to get lock in table.

Definition at line 427 of file global.cc.

bool drizzled::Session::abortLockForThread ( Table table) [inherited]

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 454 of file global.cc.

References drizzled::Table::in_use.

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

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 508 of file global.cc.

References drizzled::Table::cursor, drizzled::Table::db_stat, drizzled::Table::lock_count, drizzled::Table::lock_data_start, drizzled::Table::lock_position, drizzled::reset_lock_data_and_free(), and drizzled::Cursor::store_lock().

int drizzled::Session::lock_table_name ( TableList table_list) [inherited]

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::singleton().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 620 of file global.cc.

References drizzled::Table::in_use, and drizzled::TableList::table.

bool drizzled::Session::lock_table_names ( TableList table_list) [inherited]

Lock all tables in list with a name lock.

REQUIREMENTS

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

Definition at line 728 of file global.cc.

References lock_table(), drizzled::TableList::next_local, and drizzled::TableList::unlock_table_names().

bool drizzled::Session::lock_table_names_exclusively ( TableList table_list) [inherited]

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::singleton().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 776 of file global.cc.

References drizzled::TableList::next_global.

void drizzled::Session::removeLock ( Table table) [inherited]

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 419 of file global.cc.

static void drizzled::reset_lock_data_and_free ( DrizzleLock **  mysql_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. 2. Locking error in get_lock_data() due to missing write permission. 3. 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 163 of file global.cc.

Referenced by drizzled::Session::get_lock_data().

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

Unlock a set of external.

Definition at line 475 of file global.cc.

void drizzled::TableList::unlock_table_names ( TableList last_table = NULL) [inherited]

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::singleton().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 815 of file global.cc.

References drizzled::TableList::next_local.

Referenced by drizzled::Session::lock_table_names().

void drizzled::Session::unlockReadTables ( DrizzleLock sql_lock) [inherited]

unlock all tables locked for read.

Definition at line 344 of file global.cc.

References drizzled::Table::lock_count, drizzled::Table::lock_data_start, and drizzled::Table::lock_position.

Referenced by drizzled::Join::join_free().

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

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 330 of file global.cc.

Referenced by drizzled::Join::optimize().


Variable Documentation

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 139 of file global.cc.