Skip to content

Persistence: DynamoDB (atomic) table schema and test harness - #5830

Merged
flyrain merged 4 commits into
apache:mainfrom
ZephyrYWZhou:dynamodb-atomic-schema
Oct 27, 2026
Merged

flyrain merged 4 commits into
apache:mainfrom
ZephyrYWZhou:dynamodb-atomic-schema

Conversation

@ZephyrYWZhou

@ZephyrYWZhou ZephyrYWZhou commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Next step of the optional DynamoDB persistence backend (#5615), building on the merged skeleton (#5622) and single-table data model (#5707). This PR adds table provisioning for the dynamodb-atomic module and a test harness that runs against a real DynamoDB API, so later PRs (the BasePersistence implementation and its conformance tests) have something to run against.

Still no persistence logic and no runtime wiring — provisioning is a control-plane step, not a request path.

Design

DynamoDbSchema creates the single base table plus the by-name global secondary index, matching the keys defined in DynamoDbLayout:

  • Base table — PK (HASH) / SK (RANGE), on-demand (PAY_PER_REQUEST) billing.
  • By-name GSI (gsi1) — GSI1_PK (HASH) / GSI1_SK (RANGE), projection ALL, used to list a parent's children.

createIfAbsent is idempotent — an already-present table is validated against the expected base/GSI key schema (surfacing a misconfigured table) and otherwise left untouched — and blocks until the table is active; deleteIfExists is the teardown counterpart for tests. This is the DynamoDB equivalent of a relational schema script — a bootstrap-time step, not something on the request path.

The test harness (AbstractDynamoDbTest) starts a shared FlociAwsContainer and builds a DynamoDbClient against it — the same container the NoSQL DynamoDB module uses — with a uniquely named table per test for isolation.

Changes

  • DynamoDbSchema — createIfAbsent / deleteIfExists for the base table + by-name GSI.
  • AbstractDynamoDbTest — shared Floci-backed DynamoDB client base for container tests.
  • DynamoDbSchemaTest — asserts the provisioned key schema / GSI / projection, idempotency, and a GSI round-trip: two siblings written via EntityItem.toItem are queried back through gsi1, exercising the data model and schema end-to-end against a real DynamoDB API.
  • build.gradle.kts — add test-scope deps (polaris-floci-aws-testcontainer, testcontainers, awssdk:apache-client).

Testing

./gradlew :polaris-persistence-dynamodb-atomic:spotlessCheck checkstyleMain checkstyleTest compileJava compileTestJava and :polaris-bom:verifyBomDependencies pass. The three DynamoDbSchemaTest cases run against the Floci container and require Docker; they were not run in my local environment (no Docker daemon) and are expected to run in CI.

Scope / follow-ups

Provisioning + harness only. Next: the BasePersistence implementation (entity writes, CAS, name-sentinel, lookups, listing) with a conformance test extending BasePolarisMetaStoreManagerTest on this harness, then the factory / CDI / config wiring that makes the backend selectable.

Checklist

@ZephyrYWZhou
ZephyrYWZhou force-pushed the dynamodb-atomic-schema branch from b8bc1f9 to bdc8fe5 Compare October 21, 2026 05:49
@ZephyrYWZhou
ZephyrYWZhou marked this pull request as ready for review October 23, 2026 00:56

@orca-review-bot orca-review-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

AI-generated review. Written by an agent. It can be wrong, so please push back where it is.

Nice small step. Provisioning sits in the right place and stays off the request path. Main asks:

  • The test harness hand-rolls a per-class Floci container. FlociAwsExtension / @FlociAws already gives a shared container with startup retries. Can we use it, and move these Docker tests to intTest like the other Floci tests?
  • Can we add negative tests for verifyKeySchema: wrong PK/SK, and a missing gsi1? That's the only real logic in the PR.
  • The PR says the tests weren't run locally. Can you confirm they're green in CI?

No CHANGELOG or docs needed while the backend isn't selectable.

- Validate the active table's layout after the waiter so the create-race
  loser path is checked too, not only describeTable.
- Verify the by-name GSI projection is ALL, not just its key schema, so a
  pre-existing KEYS_ONLY gsi1 is rejected instead of returning partial rows.
- Move the Floci/Docker-backed tests to an intTest suite so :test needs no
  Docker daemon, matching the rest of the repo.
- Use @ExtendWith(FlociAwsExtension.class) + @FlociAws to share one container
  JVM-wide with startup retries, instead of hand-rolling a per-class container.
- Drop redundant testcontainers deps (exported transitively by
  polaris-floci-aws-testcontainer) and the unused apache-client test dep.
@ZephyrYWZhou

Copy link
Copy Markdown
Contributor Author

All AI reviewer comments addressed. Tagging @flyrain for the next round of review, appreciated!

flyrain
flyrain previously approved these changes Oct 26, 2026

@flyrain flyrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks @ZephyrYWZhou !

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Oct 26, 2026
flyrain
flyrain previously approved these changes Oct 27, 2026

@dimas-b dimas-b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No opinion on DynamoDB schema design, but the PR looks good to me overall. Just one minor comment.

@ZephyrYWZhou
ZephyrYWZhou requested a review from flyrain October 27, 2026 23:36
@flyrain
flyrain merged commit 71467ed into apache:main Oct 27, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Oct 27, 2026
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.

4 participants