Skip to content

Retention trusts the client clock, with no guard on what it drops #74

Closed

Description

@alexluong

Retention works out the current period from the container's clock (pg_partsmith/strategies/base.py, datetime.now()) and never compares it with the server. With the clock set to 2027-06 against data through 2026-09, one apply --allow-destructive dropped every monthly partition, including the one holding the current month, and exited 0.

Ideas, any of which would help:

  • read now() from the server, or refuse to run when client and server differ by more than a threshold
  • never drop the partition containing the server's now()
  • an optional cap on drops per run

Heads-up: I found this while testing pg-partsmith against Outpost's schema with a fair amount of LLM help. I reproduced it myself, but haven't dug deep, so treat it as a report rather than a requirement; your call on whether and how to fix it.

Activity

  1. added a commit that references this issue on Sep 29, 2026
    f09594a
  2. AlexeyShalaev commented on Sep 29, 2026

    @AlexeyShalaev
    Member

    Fixed in 1.6.0 (#77), image ghcr.io/bedrock-python/pg-partsmith:1.6.0. Plans are now made on the database's clock (SELECT now()) instead of the container's, so a container sitting in June 2027 plans for whatever month the database is in. The regression test freezes the process three years ahead and checks the current month is still attached; on 1.5.1 it fails exactly the way you described.

    Of your three ideas I took the first. The skew check and the cap on drops protect against the two clocks disagreeing, and there's no longer a second clock in that decision.

    One thing is still on the process clock: the instant a detach is stamped with, which the orphan grace period counts from. A wrong clock there shifts when an orphan gets dropped, not what gets detached. Moving it changes the repository protocol, so it'll be its own PR.

    Thanks for this one. I'd never have seen it on a machine with a correct clock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions