Skip to content

Renewal can commit a deadline that has already passed after a stall #47

Open

Description

@waldemort-auto

Summary

Since #44, renew_orchestration_item_lock reads the time once, right after it gets the per-instance advisory lock. It uses that time for both the expiry check and the new deadline. If the session then stalls for longer than the extension before it commits, it commits a deadline that has already passed. Possible causes are CPU starvation, I/O, or a commit waiting on a synchronous standby.

This does not break ownership. Renewal holds the advisory lock until it commits, so no fetch can take the instance during the stall. After the commit, the old owner's acknowledge is still fenced on its token.

The cost is efficiency: the lease looks expired as soon as it is renewed, so another worker can take the instance at once and the turn runs twice. main has the same window.

Evidence

In the TLA+ model in #44 (docs/tla/orchestration-leases), RenewalDeadlineLiveAtCommit fails with zero clock skew in a 13-state trace. See the configurations MAIN-deadline-publication, PR43-deadline-publication and FIXED-deadline-publication.

Options

  • Compute the deadline from clock_timestamp() inside the final UPDATE, and raise if it is not later than the database clock; the provider then retries the renewal.
  • Document the window and leave the code as is. The stall would have to last longer than the extension (5 s by default) inside a single call.

A commit can always stall, so neither option removes the window completely. Low priority.

Activity

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