Flashcards
SCC 201 - Concurrency Locking
Cards in this deck (45)
- 1What are concurrency control techniques used for?Used to ensure the non-interference
(isolation) property of concurrently
executing transactions - 2What is serialisability?Serializability is the major correctness criterion for concurrent transactions' executions. It is considered the highest level of isolation between transactions, and plays an essential role in concurrency control.
- 3State a protocol that guarantees serialisability?Locking based protocol
Timestamp based protocols
• Others e.g. multiversion protocols - 4What is a lock?A variable associated with a data item that
describes the status of the item with respect to possible operations that can be applied to it - 5What are locks?Locks are a means of synchronising the
access to the database by concurrent
transactions
Generally there is one lock for each data
item - 6What are the two states a binary lock can have?Can have two states or values
– Locked and unlocked (or 1 and 0 for simplicity) - 7A distinct lock is associated with each database item X? Expand on the lock values and their effects?– Lock value = 1
• X cannot be accessed by an operation that requests the item
– Lock value = 0
• X can be accessed by an operation that requests the item - 8Why are binary locks too restrictive?– At most one transaction can hold a lock
- 9What are shared lock known as and what do they enable?– Also known as a read lock
– Several transactions can hold a shared lock on a data item X if they all access X for reading purposes only - 10What are exclusive locks known as and what do they enable?– Also known as a write lock
– If a transaction is to write to an item X it must hold an exclusive lock - 11LOCK (x) state the three possible states and their operations?read-locked, write-locked and
unlocked
Operations:
– read_lock(X)
– write_lock(X)
– unlock(X) - 12What is the way of implementing the above three operations?One possible way of implementing the above three operations is to keep track of the number of transactions that hold a shared lock on an item
– no_of_reads(x) - 13What type of transaction can convert the lock from one locked state to another?A transaction that already holds a lock on
an item can be allowed, under certain
conditions, to convert the lock from one
locked state to another - 14If a transaction T is the only transaction holding a read lock, what can it upgrade to?If a transaction T is the only transaction
holding a read lock on an item it can
upgrade it to a write lock
A transaction may initially hold a write lock on an item and then later downgrade it to a read lock. - 15A database item for locking can be:– A database record
– A field value of a database record
– A disk block
– A whole file
– The whole database - 16A database item for locking can be: (Fine granularity)?- Small item sizes
- 17A database item for locking can be: (Coarse granularity)?– Large item sizes
- 18The coarser the granularity, the what?The coarser the granularity the lower is the
degree of concurrency permitted - 19What is granularity level described as in a databases?Granularity level is a disk block
- 20What is granularity?Granularity is the extent to which a system is broken down into small parts, either the system itself or its description or observation. It is the extent to which a larger entity is subdivided. For example, a yard broken into inches has finer granularity than a yard broken into feet.
- 21What are coarse grained systems?Coarse-grained systems consist of fewer, larger components than fine-grained systems; a coarse-grained description of a system regards large subcomponents while a fine-grained description regards smaller components of which the larger ones are composed.
- 22Example of granularity level referring to a disk block?– When a transaction T1 wishes to lock a
record A it must lock the whole disk block X.
– If another transaction T2 wishes to lock a different record B in the same block X it is forced to wait.
– If the granularity level was a record then T2 will be able to proceed as it will be locking a different item. - 23The finer the granularity, the what? and what does the mean in terms of the lock operations and space?The finer the granularity the larger is the
number of active locks to be handled by
the lock manager
– More lock and unlock operations Þ higher overhead
– More storage space required for the lock table - 24When might you use a fine granularity?– If a transaction typically accesses a small
number of records it is better to have the
locking granularity to be a single record - 25When might you use coarse granularity?– If a transaction typically accesses many
records in the same file it is better to have the locking granularity to be a disk block or a file. - 26What do some locking protocol support?• Some locking protocols support multiple
granularity level locking - 27What is a simple protocol that guarantees serialisability?Two-Phase locking, if all transactions follow it.
- 28What are the two phases in Two-Phase Locking?All locking operations precede the first
unlock operation:
– An expanding or growing phase (phase one)
– A shrinking phase (phase two) - 29Expand on the expand or growing phase in two phase lockingExpanding or growing phase
– New locks on items can be acquired but none can be released
– If lock conversion is allowed then upgrading of locks (read-locked to write-locked) must be carried out during this phase - 30Expand on the shrinking phase in two phase locking?Shrinking phase
– Existing locks can be released but no new locks can be acquired
– If lock conversion is allowed then downgrading of locks (write-locked to read-locked) must be carried out during this phase - 31Locking/unlocking instructions do not have to be what in terms of sequencing?Locking/unlocking instructions do not have to sequential (or grouped together), otheractivities can take place in-between
locking/unlocking instructions.
As long as all locking is completed before
the first unlock, we are following the TPL
protocol - 32When could a deadlock occur?The situation where a
process requires exclusive access to two
(or more) records.
• Both Processes A & B wish to access
records 1 & 2 - 33Three ways to solve a transaction involved in a possible deadlock situation?What to do with a transaction involved in a possible deadlock situation?
– Should it be blocked and made to wait?
– Should it be aborted?
– Should it preempt and abort another
transaction? - 34Explain the timing out process?A waiting process will only wait so long. It
then "times out" and relinquishes any active locks it holds; it then
waits some arbitrary length of time before
trying to apply its locks again. - 35The arbitrary amount of time waited should be different for each transaction, what is difficult about this?Can be difficult to decide on what this amount of time should be.
- 36When handling deadlocks, what will the DBMS do?When handling deadlocks, the DBMS will abort transactions (but those transactions are still “in the middle” of their work, and
haven’t reached the commit point). - 37• Why would the DBMS decide to abort a transaction when it asks to commit?Check video again
- 38What may be used to prevent clients from locking database resources foreverSome form of timeout may be used to
prevent clients from locking database
resources forever - 39In combination with AT and the ability to abort a client's transaction, a DBMS can do what?In combination with AT and the ability to
abort a client's transaction, a DBMS can
break a client's lock so that other, waiting
clients can have a chance to access the
locked data - 40When should a lock be broken?Break locks only when they have timed out and some other transaction is attempting to gain a conflicting lock.
- 41A lock whose time limit has been reached is called what?A lock whose time limit has been
reached is called vulnerable because a request by another transaction will cause it to be broken. - 42A transaction, some of whose locks have been broken, cannot commit because why?A transaction, some of whose locks have been broken, cannot commit because the transaction has not seen a consistent view of the data. This is why a client request to commit a transaction may result in its being aborted instead.
- 43What is the break lock approach known as?This approach is known as “pessimistic”.
• We expect trouble, and so we put
mechanisms in place to avoid it arising. - 44What is the time stamp approach known as?The “timestamp” approach is known as
“optimistic”.
• If trouble arises, we detect it and deal with the consequences. - 45Complete this statement The coarser the granularity the what?The coarser the granularity the lower is the
degree of concurrency permitted
Information
- Description
- Flashcards on SCC 201 - Concurrency Locking, created by Ayo Olutobi on 06/04/2017.
- Created by
- Ayo Olutobi
- Views
- 0
- Rating