The basic design for making transactions atomic and durable in Hustle is below.
Transaction Log
BEGIN: write a log record to storage that contains the transaction ID and the boolean false to indicate the committed state.
COMMIT: set the corresponding committed state to true.
Inserts
INSERT: create an empty log on storage with the transaction ID in the header. For each row that is inserted, write a log record to storage that contains the block ID and row ID. Then, set the row state to "tentative full".
COMMIT: scan through the log and set each row state to "full". Delete the log.
ROLLBACK or recover: scan through the log and set each row state to "empty". Delete the log.
Deletes
DELETE: create an empty log on storage with the transaction ID in the header. For each row that is deleted, write a log record to storage that contains the block ID and row ID. Then, set the row state to "tentative empty".
COMMIT: scan through the log and set each row state to "empty". Delete the log.
ROLLBACK or recover: scan through the log and set each row state to "full". Delete the log.
Updates
UPDATE: create an empty log on storage with the transaction ID in the header. For each row that is updated, write a log record to storage that contains the block ID, row ID, column ID, and old value. Then, update the row.
COMMIT: delete the log.
ROLLBACK or recover: scan through the log and set each row to the old value.
Action Items
[ ] Develop a log structure backed by stable storage that is optimized for appends.
[ ] Alter the execution operators to write to a log and perform tentative inserts and deletes.
[ ] Implement the functionality described above for BEGIN and COMMIT.
The basic design for making transactions atomic and durable in Hustle is below.
Transaction Log
BEGIN
: write a log record to storage that contains the transaction ID and the booleanfalse
to indicate the committed state.COMMIT
: set the corresponding committed state totrue
.Inserts
INSERT
: create an empty log on storage with the transaction ID in the header. For each row that is inserted, write a log record to storage that contains the block ID and row ID. Then, set the row state to "tentative full".COMMIT
: scan through the log and set each row state to "full". Delete the log.ROLLBACK
or recover: scan through the log and set each row state to "empty". Delete the log.Deletes
DELETE
: create an empty log on storage with the transaction ID in the header. For each row that is deleted, write a log record to storage that contains the block ID and row ID. Then, set the row state to "tentative empty".COMMIT
: scan through the log and set each row state to "empty". Delete the log.ROLLBACK
or recover: scan through the log and set each row state to "full". Delete the log.Updates
UPDATE
: create an empty log on storage with the transaction ID in the header. For each row that is updated, write a log record to storage that contains the block ID, row ID, column ID, and old value. Then, update the row.COMMIT
: delete the log.ROLLBACK
or recover: scan through the log and set each row to the old value.Action Items
BEGIN
andCOMMIT
.