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

Allow opening an existing DB in snapshot-only mode #13937

Merged
merged 4 commits into from
Aug 21, 2023

Conversation

npepinpe
Copy link
Member

Description

This PR adds a new API call to ZeebeDbFactory which allows opening existing databases in a snapshot-only mode. This returns a ZeebeDb which can ONLY take snapshots, and will throw a new UnsupportedOperationException for any other operations.

While it would be nice to have a proper read-only DB implementation, there are no transactions in a such a DB, and our whole access to the DB is coupled with the transaction API. As we were thinking of switching away from transactions, it will likely be easier after that to implement a read-only DB.

This will be used as part of the fix for #13775 to create the runtime directory faster via hard-links instead of a full copy.

Related issues

related to #13775

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/1.3) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • If the PR changes how BPMN processes are validated (e.g. support new BPMN element) then the Camunda modeling team should be informed to adjust the BPMN linting.

Other teams:
If the change impacts another team an issue has been created for this team, explaining what they need to do to support this change.

Please refer to our review guidelines.

Adds a new API call to `ZeebeDbFactory` which allows opening existing
databases in a snapshot-only mode. This returns a `ZeebeDb` which can
ONLY take snapshots, and will throw a `new
UnsupportedOperationException` for any other operations.

While it would be nice to have a proper read-only DB implementation,
there are no transactions in a such a DB, and our whole access to the DB
is coupled with the transaction API. As we were thinking of switching
away from transactions, it will likely be easier after that to implement
a read-only DB.
Copy link
Member

@Zelldon Zelldon left a comment

Choose a reason for hiding this comment

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

Thanks @npepinpe 🚋 🚀

@@ -56,31 +57,50 @@ public ZeebeRocksDbFactory(

@Override
public ZeebeTransactionDb<ColumnFamilyType> createDb(final File pathName) {
final ZeebeTransactionDb<ColumnFamilyType> db;
final List<AutoCloseable> closeables = Collections.synchronizedList(new ArrayList<>());
Copy link
Member

Choose a reason for hiding this comment

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

❓ Do you remember why this is actually a synchronized list 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

No idea, I just copied it and assumed we have a good reason for it 😄 Possibly it's related to creating transaction/transaction contexts from possibly many threads? 🤷

@npepinpe
Copy link
Member Author

bors merge

@zeebe-bors-camunda
Copy link
Contributor

Build succeeded:

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit eae7576 into main Aug 21, 2023
23 checks passed
@zeebe-bors-camunda zeebe-bors-camunda bot deleted the np-13775-read-only-db branch August 21, 2023 10:02
@korthout
Copy link
Member

This pull request requires a change in zeebe-process-test:

@npepinpe Please have a look

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.

None yet

3 participants