-
Notifications
You must be signed in to change notification settings - Fork 0
Operations
PawnDB provides a comprehensive set of operations for database transactions. Each table can choose to implement these operations based on its specific requirements.
Initiates a new transaction in the database.
PawnDB uses Two-Phase Locking (2-PL), which requires read operations to follow lock operations.
After any lock & read operation completes:
- Rollback Action: Append "Unlock the tuple" actions.
- Commit Action: Append "Unlock the tuple" actions.
These operations block until the record becomes available or fail after a timeout period.
Acquires a shared/exclusive lock on any/given available record.
| Error Code | Data |
|---|---|
| No Error | Locked Record Key |
| Timeout | None |
Acquires shared/exclusive locks on all records in the table.
| Error Code | Data |
|---|---|
| No Error | Locked Record Keys |
| Timeout | None |
These operations do not block. If the record is unavailable, the database returns an error instead of waiting.
Acquires an shared/exclusive lock on a record with a specific key.
| Error Code | Data |
|---|---|
| No Error | Record Key |
| Unavailable | Record Key |
| Record Not Found | Record Key |
Acquires shared/exclusive locks on all available records in a table. Any record locked elsewhere is ignored.
| Error Code | Data |
|---|---|
| No Error | Record Key List |
This operation fails if the record does not exist or is not currently locked by the transaction.
They do not generate any rollback and commit actions.
Read a record with given key.
| Error Code | Data |
|---|---|
| No Error | Serialized Record Data |
| Not Locked | Record Key |
| Not Found | Record Key |
This operation transitions a transaction from the Growing to the Shrinking phase, removing a shared lock from an acquired record.
PawnDB's strict 2-PL forbids yielding exclusive locks; such locks are only released upon commit or rollback.
The lock on the lock table will be removed immediately.
The existing rollback action for the shared lock is removed.
The existing commit action for the shared lock is removed.
| Error Code | Data |
|---|---|
| No Error | Record Key |
| Not Locked | Record Key |
| Not Found | Record Key |
This operation promotes a shared lock to exclusive and can only be used in the Growing phase.
Warning: This operation should be used with caution as it does not guarantee the promotion can be completed. If two transactions call this simultaneously, it will create a deadlock. Ensure only one transaction uses this operation at any time on a given table.
The existing rollback action for the shared lock is upgraded to exclusive unlock.
The existing commit action for the shared lock is upgraded to exclusive unlock.
| Error Code | Data |
|---|---|
| No Error | Record Key |
| Timeout | Record Key |
These operations create records that are not visible to other transactions until the creating transaction commits.
After an insert is completed successfully, the new tuple is held by an exclusive lock automatically.
Append a "Delete the inserted tuple" action.
Append an "Unlock the inserted tuple" action.
| Error Code | Data |
|---|---|
| No Error | Record Key |
| Timeout | Record Key |
Creates a record with a specified key.
PawnDB rejects duplicate keys, so this operation fails if the key already exists.
Creates a record without specifying the key.
PawnDB automatically generates a unique key for the inserted record.
Records can only be updated if they are acquired with an exclusive lock.
Append an "Update the tuple back to the original data" action.
| Error Code | Data |
|---|---|
| No Error | Record Key |
| Record Not Found | Record Key |
Updates the record with the specified key.
Records can only be deleted if they are acquired with an exclusive lock.
Delete operations generate rollback data.
Removes the record with the specified key from the table. This operation is lazy in most cases, meaning the data is simply labeled as deleted, making both commit and rollback operations easier.
Append an "Insert the orginal tuple back" action.
| Error Code | Data |
|---|---|
| No Error | Record Key |
| Record Not Locked | Record Key |
| Record Not Found | Record Key |