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

Refactor OEntityStore level transactions #192

Merged
merged 43 commits into from
Aug 23, 2024

Conversation

kirillvasilenko
Copy link
Collaborator

@kirillvasilenko kirillvasilenko commented Aug 13, 2024

EntityStore level transactions are rewritten

  1. Transaction lifecycle is changed. StoreTransaction life = ODatabaseSession life.
  2. Code that needs a transaction requires it explicitly.
  3. Code that creates transactions checks that there are no active transactions on the current thread.
  4. Added possibility to activate/deactivate transactions on the current thread.
  5. Supported read-only transactions.
  6. No code accesses ODatabaseSessions directly except for transactions and DatabaseProvider.
  7. "Embedded"/"nested" transactions are forbidden.

Changed Blob implementation

Use ORecordBytes to store blobs - a special Orient type for binary data.

Deleted OEnvironment and Co

Because its existence does not make sense.

A transaction is active/usable from our point of view only if it is in a BEGUN state
It seems that we should always use rollback(force = true), otherwise the session may get a broken state and become unusable.
The previous implementation created a session on every access to the sequence (get, increment, etc.) The new implementation creates a new session only when both the sequence has not been created yet and the current session has an active transaction. Also, the new implementation makes sure that the sequence is created right away and not lazily.
…that creates sessions

It leaves less room for bugs because the client's code does not have to deal with closing the new session and reactivating the previous one.
1. The transaction lifecycle is tightly bound to the ODatabaseSession lifecycle. Transactions start and finish with sessions.
2. Transaction can be read-only.
3. Transactions validate their state on every operation.
4. OEntityStore does not let create several transactions on a single thread.
5. Get rid of the code for nested/embedded transactions
@kirillvasilenko kirillvasilenko changed the title Rewrite OEntityStore level transactions Refactor OEntityStore level transactions Aug 13, 2024
Sessions should not be accessible for client code. They are implementation details and very fragile. Never touch a session.
# Conflicts:
#	entity-store/src/main/kotlin/jetbrains/exodus/entitystore/orientdb/query/OQueryExecution.kt
…leBase. count() and roughCount() behave as size() and roughSize() now.

This countExecutor activated the session on another thread that caused a bunch of concurrency related bugs. Decided not to calculate anything in the background until it is necessary.
not to access ODatabaseSession directly, rewrite blob-related code

1. OVertexEntity should never access ODatabaseSession directly.
2. Blob-related logic does not create additional/artificial/extra records to handle blobs. Now we use ORecordBytes to store the actual data. It is a special Oreint data type for such use-cases.
@kirillvasilenko kirillvasilenko marked this pull request as ready for review August 22, 2024 08:58
Copy link
Collaborator

@leostryuk leostryuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@kirillvasilenko kirillvasilenko merged commit 500bc0b into graph-store Aug 23, 2024
1 check passed
@kirillvasilenko kirillvasilenko deleted the fix-otransaction-commit-flush branch August 23, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants