Skip to content

Add "table repacker" maintenance services that runs REPACK (CONCURRENTLY)#1228

Draft
brandur wants to merge 1 commit intomasterfrom
brandur-table-repacker
Draft

Add "table repacker" maintenance services that runs REPACK (CONCURRENTLY)#1228
brandur wants to merge 1 commit intomasterfrom
brandur-table-repacker

Conversation

@brandur
Copy link
Copy Markdown
Contributor

@brandur brandur commented Apr 25, 2026

Here, add a maintenance service modeled on the reindexer that runs
REPACK (CONCURRENTLY), a new feature slated for Postgres 19 [1]. This
is an exciting new feature that can fully reset a table without needing
to take an exclusive lock the way that VACUUM FULL does.

This feature may be on the riskier side at first, so I've disabled it by
default, requiring an explicit RepackerEnabled: true to activate.

Similar to the reindexer it runs once a day. I've staggered its start
time to 1 AM UTC so it's offset from the reindexer's start time of
midnight.

This relies on Postgres 19 to work, so it's not really suitable for
release yet, but I've put in fallback code that causes it to run VACUUM FULL for Postgres prior to 19. (This is obviously not suitable for use,
but it gets the test matrix running.)

[1] postgres/postgres@28d534e

…NTLY)`

Here, add a maintenance service modeled on the reindexer that runs
`REPACK (CONCURRENTLY)`, a new feature slated for Postgres 19 [1]. This
is an exciting new feature that can fully reset a table without needing
to take an exclusive lock the way that `VACUUM FULL` does.

This feature may be on the riskier side at first, so I've disabled it by
default, requiring an explicit `RepackerEnabled: true` to activate.

Similar to the reindexer it runs once a day. I've staggered its start
time to 1 AM UTC so it's offset from the reindexer's start time of
midnight.

This relies on Postgres 19 to work, so it's not really suitable for
release yet, but I've put in fallback code that causes it to run `VACUUM
FULL` for Postgres prior to 19. (This is obviously not suitable for use,
but it gets the test matrix running.)

[1] postgres/postgres@28d534e
brandur added a commit that referenced this pull request Apr 25, 2026
I just noticed while putting together #1228 that we have an unused
constant in the reindexer, `ReindexerIntervalDefault`, as some time back
the interval was replaced by a schedule func. Here, drop it.
@brandur
Copy link
Copy Markdown
Contributor Author

brandur commented Apr 26, 2026

Actually, two addendums upon further thought:

  • If the repacker is on, we'd want to disable the reindexer for that table. Indexes are rebuilt on repack, so it'd be added work for now good reason.
  • We may just want to make the repacker + reindexer the same service since they're fairly interrelated. It'd also guarantee only one of them is doing anything at any given time.

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.

1 participant