Transactions

15 flashcardsby Nijelous
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
Transactions
A sequence of information exchange used for controlling operations on persistent shared information

Include multiple procedure calls, and ensure that only consistent state changes to object take place
2
Persistent data
Any data that is stored and not lost after the application is terminated or power to the device is shut off. Disk based & long lived.
3
ACID
A set of properties a transaction needs to ensure.

Atomicity: All or nothing, everything is reverted in the event of a failure.

Consistency: Transactions run such that they execute with no interference, and must fully execute on all machines they will access first before the next one can.

Independence: Updates performed by transactions are visible to transactions only after it terminates.

Durability: Results produced by successfully terminated transactions are not destroyed by subsequent failures.
4
Transaction Primitives
Basic operations required for transactions to work

Begin-transaction: Command to start transaction

End-transaction: "Commit" protocol, terminates transaction with one of two outcomes while releasing locks:
-Normal Termination (commit): Updates migrated to disk (durable)
-Aborted Termination (aborts): No results produces

Abort: Explicitly aborts transaction executing
5
Concurrency Control
A method of dealing with a situation in which two or more users or applications need to access the same record at the same time.

Used for shared objects (reading, writing, locks)

While one transaction is running, all of its locks are held
6
Serial Schedules
An order of transactions being enacted that produces results from a transaction before the other can cause meaningful changes.

If too much happens concurrently, these are not produced, and we want as many of these as possible.
7
Locks
A signal that ensures that only that transaction can access that part of shared data.

Used for concurrency control, locking an object before using it
8
Rules of Locks
Write Lock: Exclusive, only available if there are NO locks applied to the data (read or write)

Read Lock: Available to any machine at any time so long as a write lock hasn't been acquired

Can be conflicts (write-write, write-read or read-write)
9
Two-Phase Locking
A form of deadlock prevention.
Works in two phases:
Growing Phase: Locks are acquired, no locks released
Shrinking Phase: Acquired locks are released as they are no longer needed, no locks acquired

A transaction must obtain a lock before using it
10
Strict Two-Phase Locking
Holds all the locks until the lock point and releases all the locks at once.

No shrinking phase.
11
Deadlock Prevention: Simple
Transactions never wait, and will abort if it cannot obtain a lock.

Effective if conflicts are rare, but can cause many unnecessary aborts on popular objects.
12
Deadlock Prevention: Wait Die
Aka Wait (Old) Die (Young) (WODY)

If the requesting transaction is older than the holding transaction, then it waits
-Requesting timestamp < Holding timestamp

If the requesting transaction is younger than the holding transaction, it aborts
-Requesting timestamp > Holding timestamp
13
Deadlock Prevention: Wound Wait
Aka Wound (Old) Wait (Young) (WOWY)

If the requesting transaction is younger than the holding transaction, it waits
-Requesting timestamp > Holding timestamp

If the requesting transaction is older than the holding transaction, then the requesting transaction forces the holding to release its locks and abort (at end-transaction)
-Requesting timestamp < Holding timestamp
14
Two-Phase Commit: General Information
A mechanism that is another control used in transactions to ensure atomicity.

Implements strict 2PL

Uses a crash-proof storage (Stable storage), with data being stored on n+1 disks, allowing for n crashes.

Clients and servers make changes on copies of objects, rather than the original.
-If aborted, copies are discarded
-If committed, copies are forced to stable store, then treated as new versions. Old versions are discarded.
15
Two-Phase Commit: Mechanism
Using a coordinator client, works in two phases

Phase One: Coordinator sends a message to each client to determine the outcome for a transaction, confirming everything has happened as expected.

Phase Two: Enforced the decision.

Each client node maintains a transaction log in stable storage, which is scanned in phase one to check for crashes. Crashes are logged by a recovery manager process, which terminates transactions interrupted by crash.

Blocking protocol, can lead to servers waiting a while for the coordinator to recover.
Study all 15 cards for free