Drizzled Public API Documentation

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

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

Abort all other threads waiting to get lock in table.

Definition at line 430 of file global.cc.

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

References drizzled::Table::in_use.

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

Referenced by drizzled::Session::close_old_data_files(), drizzled::Open_tables_state::close_open_tables(), drizzled::Session::reopen_tables(), drizzled::Session::unlink_open_table(), and drizzled::TableList::unlock_table_names().

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 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)

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

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

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

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

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

References drizzled::TableList::next_global.

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

static 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.

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

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

Unlock a set of external.

Definition at line 475 of file global.cc.

References drizzled::Table::current_lock.

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

References drizzled::locking::broadcast_refresh(), and drizzled::TableList::next_local.

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

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

unlock all tables locked for read.

Definition at line 347 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 
)

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