Repository navigation
Persistence: DynamoDB (atomic) entity writes, CAS and name uniqueness - #5892
Conversation
orca-review-bot
left a comment
There was a problem hiding this comment.
Nice, careful first cut. The sentinel-ownership check on delete and the rethrow of non-conflict cancels are both good calls. The main thing to settle is how two failure paths land in AtomicOperationMetaStoreManager: the version-checked delete, and the create 'retry' fallbacks. Details are inline.
Tests: can we add an IT where the entity gets updated between the caller's read and deleteEntity, plus one for an id clash with a different name? A single test through createEntityIfNotExists / dropEntityIfExists would also catch mapping drift before the shared BasePolarisMetaStoreManagerTest arrives.
No CHANGELOG entry is needed while the backend isn't wired. Realm prefixing and the catalog/type filtering on lookups match JDBC.
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
|
Finished incorporating ORCA's feedback and polishing the changes. Tagging @flyrain for the next round of review! |
flyrain
left a comment
There was a problem hiding this comment.
Thanks for the working on it, @ZephyrYWZhou ! Left some comments.
flyrain
left a comment
There was a problem hiding this comment.
+1 Thanks @ZephyrYWZhou for working on it!
Summary
Next step of the optional DynamoDB persistence backend (#5615), building on the skeleton (#5622), the single-table data model (#5707) and the schema + test harness (#5830). This PR adds the first
BasePersistenceimplementation: entity writes, per-entity compare-and-set, and name uniqueness, plus the by-id and by-name lookups.Still no runtime wiring, so the backend cannot be selected yet. Operations not covered here throw
UnsupportedOperationExceptionand land in follow-ups.Design
DynamoDbBasePersistenceruns under the existingAtomicOperationMetaStoreManager. Every correctness decision rides a strongly consistent single-item read or a conditional write:TransactWriteItemsputs the entity item and its name sentinel, bothattribute_not_exists, so ids and names stay unique.PutItem, CAS on bothentityVersionandgrantRecordsVersion(grant changes bump only the latter, same as JDBC).GetItem/BatchGetItem; by-name goes through the sentinel, never the GSI.Failures map to the exceptions the manager already handles:
EntityAlreadyExistsException(name collision)EntityAlreadyExistsExceptionwith the same id (idempotent create retry)RetryOnConcurrencyExceptionA few edge cases are handled explicitly:
nameOrParentChanged=trueon some updates where the name is unchanged; that stays a plain update rather than deleting and re-putting the same sentinel.Changes
DynamoDbBasePersistence— entity writes and lookups as above.IdGenerator— positive 63-bit random ids, same as therelational-jdbcgenerator.TransactionFailures— reads per-action cancellation reasons of aTransactWriteItems, and tells conflicts apart from other failures.DynamoDbBasePersistenceIT— create/read, stale-version rejection, duplicate name, idempotent create, rename and re-parent, rename onto a taken name, delete, the stale-delete case, and batch lookups across chunks with repeated and missing ids, against the Floci harness.TransactionFailuresTest— unit tests for the cancellation-reason mapping.build.gradle.kts—compileOnly(libs.jspecify), as inrelational-jdbc.package-info.java— drop the outdated "skeleton only" note.Testing
./gradlew :polaris-persistence-dynamodb-atomic:spotlessCheck checkstyleMain checkstyleTest checkstyleIntTest compileIntTestJava test javadocpasses.DynamoDbBasePersistenceITneeds Docker and runs in CI (Other Integration Tests), where it passes.Scope / follow-ups
Next:
listEntities/hasChildren(by-name GSI + page token), thenwriteEntities, then grant records with the by-grantee GSI, then principal secrets, policy mappings and the sharedBasePolarisMetaStoreManagerTest, and finally the factory / CDI / config wiring.Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)