vault backup: 2024-02-20 13:42:29
This commit is contained in:
46
.obsidian/workspace.json
vendored
46
.obsidian/workspace.json
vendored
@@ -6,7 +6,6 @@
|
||||
{
|
||||
"id": "7b5e68cfd661dd0d",
|
||||
"type": "tabs",
|
||||
"dimension": 61.240310077519375,
|
||||
"children": [
|
||||
{
|
||||
"id": "505b4bbc8a7e15f6",
|
||||
@@ -14,30 +13,13 @@
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Semester 2/Database Systems/Week 5/Week 5 Database Systems.md",
|
||||
"file": "Semester 2/Database Systems/Week 6/Week 6 Database Systems.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0df2a38b58c879ff",
|
||||
"type": "tabs",
|
||||
"dimension": 38.759689922480625,
|
||||
"children": [
|
||||
{
|
||||
"id": "a9b5c2a99473859a",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "pdf",
|
||||
"state": {
|
||||
"file": "Semester 2/Database Systems/Exercise Booklet.pdf"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "vertical"
|
||||
@@ -104,7 +86,7 @@
|
||||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"file": "Semester 2/Database Systems/Week 5/Week 5 Database Systems.md",
|
||||
"file": "Semester 2/Database Systems/Week 6/Week 6 Database Systems.md",
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
@@ -121,7 +103,7 @@
|
||||
"state": {
|
||||
"type": "outgoing-link",
|
||||
"state": {
|
||||
"file": "Semester 2/Database Systems/Week 5/Week 5 Database Systems.md",
|
||||
"file": "Semester 2/Database Systems/Week 6/Week 6 Database Systems.md",
|
||||
"linksCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
}
|
||||
@@ -144,7 +126,7 @@
|
||||
"state": {
|
||||
"type": "outline",
|
||||
"state": {
|
||||
"file": "Semester 2/Database Systems/Week 5/Week 5 Database Systems.md"
|
||||
"file": "Semester 2/Database Systems/Week 6/Week 6 Database Systems.md"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -184,8 +166,17 @@
|
||||
"switcher:Open quick switcher": false
|
||||
}
|
||||
},
|
||||
"active": "ff4e63a36b080692",
|
||||
"active": "505b4bbc8a7e15f6",
|
||||
"lastOpenFiles": [
|
||||
"images/Pasted image 20240220132550.png",
|
||||
"images/Pasted image 20240220132521.png",
|
||||
"images/Pasted image 20240220132154.png",
|
||||
"images/Pasted image 20240220132113.png",
|
||||
"images/Pasted image 20240220131641.png",
|
||||
"images/Pasted image 20240220131547.png",
|
||||
"Semester 2/Database Systems/Week 5/Week 5 Database Systems.md",
|
||||
"Semester 2/Database Systems/Week 6/Week 6 Database Systems.md",
|
||||
"Semester 2/Database Systems/Week 6",
|
||||
"Semester 2/Programming 2/Project/Part 2/Library.java#",
|
||||
"Semester 2/Programming 2/Project/Part 2/Periodical.java#",
|
||||
"Semester 2/Programming 2/Project/Part 2/data/item_data_2.txt",
|
||||
@@ -195,19 +186,11 @@
|
||||
"Semester 2/Programming 2/Project/Part 2/LibraryItem.ctxt",
|
||||
"Semester 2/Programming 2/Project/Part 2/LibraryItem.class",
|
||||
"Semester 2/Programming 2/Project/Part 2/LibraryItem.java#",
|
||||
"Semester 2/Programming 2/Project/Part 2/LibraryItem.java",
|
||||
"Semester 2/Programming 2/Project/Part 2/__SHELL63.class",
|
||||
"Semester 2/Programming 2/Project/Part 2/Part 1/doc/resources/inherit.gif",
|
||||
"Semester 2/Programming 2/Project/Part 2/doc/resources/inherit.gif",
|
||||
"Semester 2/Programming 2/Project/Part 1 (copy)/doc/resources/inherit.gif",
|
||||
"images/Pasted image 20240213172702.png",
|
||||
"images/Pasted image 20240213172509.png",
|
||||
"images/Pasted image 20240213172304.png",
|
||||
"Semester 2/Database Systems/Week 5/Week 5 Database Systems.md",
|
||||
"images/Pasted image 20240213161136.png",
|
||||
"images/Pasted image 20240213133455.png",
|
||||
"images/Pasted image 20240213132603.png",
|
||||
"images/Pasted image 20240213132227.png",
|
||||
"Semester 2/Database Systems/Week 4/Week 4 Database Systems.md",
|
||||
"Semester 2/HCI/Week 2/Week 2 Human Computer Interfaces.md",
|
||||
"Semester 2/HCI/Week 3/Week 3 Human Computer Interfaces.md",
|
||||
@@ -231,7 +214,6 @@
|
||||
"Semester 2/Programming 2/Week 2/Week 2 Programming 2.md",
|
||||
"Semester 2/Programming 2/Week 1/Week 1 Programming 2.md",
|
||||
"Semester 2/Programming 2/README.md",
|
||||
"Semester 2/HCI/README.md",
|
||||
"Database Systems/Untitled.canvas",
|
||||
"Untitled 1.canvas",
|
||||
"Untitled.canvas"
|
||||
|
@@ -0,0 +1,66 @@
|
||||
# Locks
|
||||
|
||||
Transactions can ask DBMS to place locks on data items in the database.
|
||||
Locks prevent another transaction from modifying data, or in the case of an exclusive lock, reading too.
|
||||
Locks are implemented by inserting a flag on the object, or in a list of locked parts.
|
||||
Objects of various sizes can be locked ( database, table, tuple, data item ), the size determines the granularity.
|
||||
|
||||
## Exclusive Locks
|
||||
|
||||
Necessary for write access - gives exclusive access to an item.
|
||||
If a transaction has an exclusive lock on an item, it can both read and update the item.
|
||||
Writes can conflict, so only one transaction can lock an item for writing.
|
||||
|
||||
## Shared Locks
|
||||
|
||||
Sufficient for read-only access.
|
||||
If a transaction has a shared lock on an item, it can read, but not update, the item.
|
||||
Reads cannot conflict, more than one transaction can hold shared locks simultaneously.
|
||||
|
||||
## Usage
|
||||
|
||||
Any transaction accessing data must first lock the item by requesting
|
||||
|
||||
- Shared Lock ( Read-Only Access )
|
||||
- Exclusive Lock ( Read & Write Access )
|
||||
If the item is not already locked, the lock will be granted.
|
||||
If the item is locked, the DBMS determines the compatibility of the requested lock and the existing lock.
|
||||
- If shared lock requested on an item with a shared lock, the request is granted.
|
||||
- Otherwise, the transaction must wait until lock released.
|
||||
A transaction holds a lock until explicit release during execution / termination.
|
||||
|
||||
## Two-Phase Locking ( 2PL )
|
||||
|
||||
Transaction follows 2PL protocol if all locking operations precede first unlock operation in the transaction.
|
||||
Each transaction divided into 2 phases:
|
||||
|
||||
- Growing Phase: acquires all locks, but cannot release.
|
||||
- Shrinking Phase: releases all locks, but cannot acquire.
|
||||
No requirement for locks to be obtained simultaneously.
|
||||
Rules:
|
||||
- Transaction must acquire a read or write lock before operating on an item.
|
||||
- On release, the transaction may not acquire new locks.
|
||||
|
||||
### Observations on 2PL
|
||||
|
||||
- If every transaction follows 2PL, the schedule is guaranteed to be conflict serialisable.
|
||||
- However, 2PL does not permit all possible serialisable schedules, or prevent deadlocks.
|
||||
- Variations of 2PL exist, but lie outside of our scope.
|
||||
|
||||
## Lost Update Problem
|
||||
|
||||
- 
|
||||
We can prevent this issue by utilising exclusive locks, not allowing T1 to perform any conflicting operations before T2 has committed and unlocked balx:
|
||||
- 
|
||||
|
||||
## Uncommitted Dependency Problem
|
||||
|
||||
- 
|
||||
Similarly to the previous issue, we can solve this by locking T3 until the data item is unlocked by T4 to preserve consistency.
|
||||
- 
|
||||
|
||||
## Inconsistent Analysis Problem
|
||||
|
||||
- 
|
||||
We can solve this issue by locking the data items appropriately. By write locking balx and balz in T5, T6 must wait to modify or read any data from either of these data items to preserve consistency.
|
||||
- 
|
BIN
images/Pasted image 20240220131547.png
Normal file
BIN
images/Pasted image 20240220131547.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
BIN
images/Pasted image 20240220131641.png
Normal file
BIN
images/Pasted image 20240220131641.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
BIN
images/Pasted image 20240220132113.png
Normal file
BIN
images/Pasted image 20240220132113.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
BIN
images/Pasted image 20240220132154.png
Normal file
BIN
images/Pasted image 20240220132154.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
BIN
images/Pasted image 20240220132521.png
Normal file
BIN
images/Pasted image 20240220132521.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 81 KiB |
BIN
images/Pasted image 20240220132550.png
Normal file
BIN
images/Pasted image 20240220132550.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
Reference in New Issue
Block a user