Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Memory transaction #1392

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

codernineteen
Copy link
Contributor

@codernineteen codernineteen commented Aug 31, 2023

resolved #373

Memory transaction support to resolve issue #373.

Implementation details and changes are below:

  • added undo.rs to optimize rollback functionality by restoring previous logs in buffer.
  • a definition of new enum 'Log' and its variants
  • storing statement log whenever there is an execution
  • test cases for the implementation

p.s. I deleted commits in my forked repository by mistake and the previous pull request #1360 was closed unexpectedly.

For this draft pull request, i used naive approach, which is called as 'snapshot' to memoize previous state.
With this strategy, the transaction implementation follows few steps
1. capture a snapshot of the current state of memory storage at the moment when a transaction starts
2. In transaction trait impl block, it checks what the current storage transacion state is
 2.a - If there is no transaction and it is not autocommit, memory storage set snapshot and begin process
 2.b - If there is no transaction and a incoming transaction is autocommit, mem storage doens't memorize snapshot and just do the process right away
 2.c - If there is a transaction being processed already, mem storage abort the incoming storage in this phase
3. If there is a rollback request during transaction process, mem storage use snapshot to recover data and set 'None' to snapshot field.
4. If there is a commit request, mem storage decided to end of transaction and reflect the changes into storage
5. In both cases of rollback request and commit request, we set transaction state of a mem storage as 'Idle' again so that it can handle future transactions
- error.rs
- stage.rs
I removed snapshot file because implementation of action-based transaction is done at this moment.
…ucture

Log-based datastructure is basically simple stack structure
It stores logs of statement execution and a set of data related to the statement.
@coveralls
Copy link

coveralls commented Aug 31, 2023

Pull Request Test Coverage Report for Build 6036564413

  • 169 of 183 (92.35%) changed or added relevant lines in 5 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.03%) to 99.162%

Changes Missing Coverage Covered Lines Changed/Added Lines %
storages/memory-storage/src/transaction.rs 12 15 80.0%
storages/memory-storage/src/undo.rs 74 85 87.06%
Files with Coverage Reduction New Missed Lines %
storages/memory-storage/src/lib.rs 2 97.89%
Totals Coverage Status
Change from base Build 6011252547: -0.03%
Covered Lines: 49357
Relevant Lines: 49774

💛 - Coveralls

@ever0de ever0de added the enhancement New feature or request label Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MemoryStorage TRANSACTION support
3 participants