Skip to content

docs(readme): warn that a broken index ordering may have admitted duplicates - #194

Merged
robrigo merged 1 commit into
mainfrom
docs/reindex-duplicate-risk
Aug 24, 2026
Merged

docs(readme): warn that a broken index ordering may have admitted duplicates#194
robrigo merged 1 commit into
mainfrom
docs/reindex-duplicate-risk

Conversation

@robrigo

@robrigo robrigo commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Why

A live operator case closed the loop on the entry added in #188, and it exposed two gaps.

bt_index_check returned item order invariant violated for index "atomicassets_schemas_pkey", meaning entries were stored out of sort order. The entry told operators an error names the damage but gave them nothing to match against, and the phrasing implied heapallindexed was the point of the check when an ordering violation aborts it before that pass ever runs.

The repair guidance stopped at the commands. Reindexing the single index the constraint needed makes the filler resume, which invites stopping there while every other index built under the old collation stays wrong. More seriously, uniqueness is enforced through the same ordering, so a corrupt unique index can have admitted rows it should have rejected. That surfaces later as a reindex failing on a duplicate key, and without warning it reads as a reindex problem rather than as data damage that has to be cleaned up first.

Validation

Documentation only, no code paths touched. The added claims are drawn from a confirmed case: the amcheck error text is quoted from an operator's Postgres output, and the reader was wedged at the block immediately before the failing range, consistent with the constraint failing on a row present in the heap. Checked the added lines for em-dash and over-length wrapping, and the fence count stays even.

Copilot AI 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.

Pull request overview

Clarifies PostgreSQL index-corruption diagnosis and recovery guidance.

Changes:

  • Explains item order invariant violated.
  • Warns that corrupt unique indexes may admit duplicates.
  • Documents concurrent reindexing risks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md Outdated
…licates

An operator who reindexes the one index the foreign key needed will see the
filler resume and reasonably stop there, while the rest of the database still
carries indexes built under the old collation. Worse, the same broken ordering
governs uniqueness checks, so a corrupt unique index can have accepted rows it
should have rejected. That surfaces as a reindex failing on a duplicate key,
which reads as a problem with the reindex rather than as the data damage it
is. Naming the amcheck error text as well gives operators something to match
against, since the ordering violation aborts the check before the
heapallindexed pass it was nominally run for.

Signed-off-by: Rob Konsdorf <rob@facings.io>
@robrigo
robrigo force-pushed the docs/reindex-duplicate-risk branch from f2aad36 to 5f90fe6 Compare August 24, 2026 13:42
@robrigo
robrigo merged commit 2e5e280 into main Aug 24, 2026
7 checks passed
@robrigo
robrigo deleted the docs/reindex-duplicate-risk branch August 24, 2026 13:45
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.

2 participants