You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DynamoDB (atomic): keep a strongly consistent child record in the base table for listing #6119
The DynamoDB (atomic) backend (#5615) lists a parent's children through the gsi1 global secondary index (gsi1pk = realmId#catalogId#parentId#typeCode, gsi1sk = the padded entity id, from #6006). A GSI is eventually consistent, and DynamoDB does not allow a strongly consistent read on one.
The problem
Some listings drive a correctness decision, not just discovery:
a namespace drop checks whether the namespace is empty;
location-overlap validation checks for a sibling.
Because gsi1 can lag, a create that already completed may be missing from the index for a moment. So a drop can wrongly treat a non-empty namespace as empty, and overlap validation can miss a newly created sibling. This happens even for sequential requests, so it is not covered by the existing concurrency TODO. (Raised by @flyrain on #6016.)
Proposed fix
Keep a strongly consistent child record in the base table, so listing can read children with ConsistentRead=true instead of the lagging index.
A child record keyed by the parent's coordinates (realmId#catalogId#parentId#typeCode) with the child id in the sort key (CHILD#<padded-id>), payload is the child id.
Written in the same TransactWriteItems as the entity: added on create, moved on re-parent, removed on delete. A pure rename leaves it in place, since it is keyed by parent and id, not name.
This PR is the write side only. gsi1 and listing are unchanged here; a follow-up (reworking #6016) switches listEntities/hasChildren to a base-table Query with ConsistentRead=true and removes gsi1. The child record has to exist before listing can read it, hence the split.
Acceptance Criteria
A create writes a child record in the base table, in the same transaction as the entity.
A re-parent moves the child record; a pure rename leaves it in place.
A delete removes the child record.
gsi1 and the listing paths are unchanged in this PR.
Activity