Skip to content

store: Fix postponed indexes of copies and grafts - #6761

Draft
dimitrovmaksim wants to merge 2 commits into
masterfrom
fix/copy-postponed-indexes-flag
Draft

dimitrovmaksim wants to merge 2 commits into
masterfrom
fix/copy-postponed-indexes-flag

Conversation

@dimitrovmaksim

@dimitrovmaksim dimitrovmaksim commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #6749

At the end of a copy or graft, create_indexes recreated the postponed indexes that existed on the source and then always marked the destination as having built them. If the source hadn't built them yet, the destination never got them. Entity types that a graft added never got theirs either.

Commits

  • store: Skip postponed indexes that already exist under another name. The background build of postponed indexes now compares index shape, not name. Names contain table and column positions, which can differ between a copy and its source, and older versions copied indexes under the source's names. Only valid indexes count, so the leftover of an interrupted build is still dropped and rebuilt.
  • store: Copy postponed indexes of a graft/copy source under own names. The copy reads the source's postponed_indexes_created flag when it starts, on the source's shard. At the end, the destination builds its own postponed indexes for the columns the source has indexed, and for columns and entity types the source doesn't have. They are named for the destination. The destination then gets the source's flag, which also clears a flag an older version set before the copy was interrupted.

Tests

New graft tests in store/test-store/tests/postgres/graft.rs and unit tests in store/postgres/src/relational/index.rs.

The background build of postponed indexes skipped an index only if one
with the same name existed. Index names contain the positions of the
table and the column. A copy's positions can differ from its source's,
and older versions copied indexes under the source's names. If such a
copy's flag was reset, the build added a second index on every shifted
column.

The build now compares the shape of the indexes, not their names. It
only counts valid indexes, so that the leftover of an interrupted build
is still dropped and rebuilt.
At the end of a copy or graft, `create_indexes` recreated the postponed
indexes that existed on the source. It then always marked the
destination as having built them. If the source hadn't built them yet,
the destination never got them. Entity types that a graft added never
got theirs either.

The copy now reads the source's flag when it starts, before the source's
indexes and on the source's shard. At the end, the destination gets its
own postponed indexes for the columns the source has indexed, and for
columns and entity types the source doesn't have. They are named for the
destination, so its own build later doesn't add a second index on a
column whose position changed. The destination then gets the source's
flag. This also clears a flag that an older version set before the copy
was interrupted.

Fixes #6749
@dimitrovmaksim
dimitrovmaksim force-pushed the fix/copy-postponed-indexes-flag branch from 89ff7f7 to 0d0f6bc Compare November 10, 2026 13:53

This branch has not been deployed

No deployments
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.

Grafted deployments (and graphman copy) never build their postponed attribute indexes when the base had not built them yet (v0.45.0 regression)

1 participant