New monthly database partitions stop being created after a server's first start-up; item writes would eventually fail

Open
#218 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
postgresql, python
Domain
backend, databases

Research direction

Start with the partition creation logic in app/src/lib/db/migrate.ts around line 1842 and decision record 0012, then trace how the pipeline runs scheduled work. Add a frozen-clock test that checks the next month's partition after the last pre-created month; done when that test passes and decision record 0012 describes the actual behavior.

Written by the indexing model from the issue text.

Description

bug ready

Found in the 2026-11-29 whole-repo review. The once-only flag is verified; the consequence was traced by a reviewer and should be confirmed with a test.

Problem

Two tables are split into one partition per month (the catalog change log item_events and audit_log). The code that creates upcoming partitions lives in the start-up migration routine, which is guarded by let migrated = false; ... if (migrated) return; (app/src/lib/db/migrate.ts ~line 1842). So it runs once per server process. Decision record 0012 assumes it runs on any request. The pipeline never creates partitions and there is no catch-all partition.

How it goes wrong

A server that stays up for a few months without a redeploy runs out of partitions. The trigger that records catalog changes then fails, which aborts every item write; audit inserts fail silently.

Suggested fix

Create partitions on a schedule (a pipeline timer or a scheduled job), separate from the once-only migrations. Add a catch-all partition as a safety net and alert if it ever receives rows.

Acceptance criteria

  • Test with a frozen clock: after the process has been up past the last pre-created month, the next month's partition exists
  • Decision record 0012 matches the behaviour
Dominant language
Python
Stars
0
Forks
2
Avg merge
8h 26m
Merged PRs (30d)
47

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TechTraverse/stac-higher

All issues in TechTraverse/stac-higher

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.