-
Notifications
You must be signed in to change notification settings - Fork 490
Make entity drop and cleanup task creation atomic #5095
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
base: main
Are you sure you want to change the base?
Changes from all commits
a3785bf
489547a
f74982f
92afc9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,6 +285,32 @@ public void deleteEntity(@NonNull PolarisCallContext callCtx, @NonNull PolarisBa | |
| runActionInTransaction(callCtx, () -> this.deleteEntityInCurrentTxn(callCtx, entity)); | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override | ||
| public void deleteEntityAndCreateEntities( | ||
| @NonNull PolarisCallContext callCtx, | ||
| @NonNull PolarisBaseEntity entityToDelete, | ||
| @NonNull List<PolarisBaseEntity> entitiesToCreate) { | ||
| runActionInTransaction( | ||
| callCtx, | ||
| () -> { | ||
| this.deleteEntityInCurrentTxn(callCtx, entityToDelete); | ||
| for (PolarisBaseEntity entityToCreate : entitiesToCreate) { | ||
| try { | ||
| this.checkConditionsForWriteEntityInCurrentTxn(callCtx, entityToCreate, null); | ||
| } catch (EntityAlreadyExistsException e) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a behavior change here, as it can now escape Previously, the code ignored the result of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @jbonofre, Thanks for your feedback! I updated the drop path so The same-ID case is still treated as an idempotent retry, while the same-name/different-ID case is returned as a conflict. I also added the retry recovery path where, if the entity is already dropped but At the service boundary, |
||
| // Matching ids indicate a retried create whose id was already reserved for the same | ||
| // entity. Treat that as idempotent, matching writeEntities. | ||
| if (e.getExistingEntity().getId() != entityToCreate.getId()) { | ||
| throw e; | ||
| } | ||
| continue; | ||
| } | ||
| this.writeEntityInCurrentTxn(callCtx, entityToCreate, true, null); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override | ||
| public void deleteFromGrantRecords( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be related to the bigger multi-entity change discussion on
dev: https://lists.apache.org/thread/vx0k8ow4k87m4y7cxpmojb0zy17t5ldyI think we need to reach consensus on that thread "in general" before making code-level improvements,