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): sort the children index (gsi1) by entity id to match id-based paging #6005
The DynamoDB (atomic) backend (#5615) keeps a children index, gsi1, for listing. It was added with the single-table data model (#5707) and the schema (#5830):
gsi1pk = realmId#catalogId#parentId#typeCode (one parent and type)
gsi1sk = the entity name
Nothing reads gsi1 yet. It will back listEntities, listFullEntities and hasChildren in the next PR of the series.
The problem
Polaris pages listings by entity id. JdbcBasePersistenceImpl orders children by id, and the shared EntityIdToken resumes with "id greater than the last one returned". With gsi1sk set to the name, gsi1 returns children in name order, so it cannot resume from an EntityIdToken.
Two ways around that are worse:
Read every child of the parent, sort by id in memory, then cut out one page (what the draft in DynamoDB (atomic) persistence backend [draft/showcase] #5694 does). Each page then reads the whole parent, for example 10,000 items per page for a namespace with 10,000 tables.
Add a name-based page token. That means a new token type in polaris-core, and DynamoDB would page differently from JDBC.
Proposed fix
Make gsi1sk the entity id, zero-padded to 19 digits so that string order matches numeric order. Then a listing is one Query with gsi1sk > pad(lastId) and a page-size limit, and EntityIdToken works unchanged.
EntityItem: write the padded id into gsi1sk instead of the name.
DynamoDbLayout: add a helper for the padded value and update the comments that call gsi1 a by-name index. By-name lookups already go through the name sentinel, not gsi1.
EntityItemTest, DynamoDbSchemaIT: expect the id-based sort key.
gsi1sk stays a string attribute, so the table and index definitions in DynamoDbSchema do not change. The backend cannot be selected yet, so no existing data is affected.
Acceptance Criteria
gsi1sk on an entity item holds its id, zero-padded to 19 digits.
Querying gsi1 for one parent returns its children in id order.
No change to the table or index definitions, or to by-id and by-name lookups.
Activity