Skip to content

Never report a publish the database did not keep - #26

Merged
henry-mosh merged 2 commits into
mainfrom
fix/managed-content-connection-loss
Dec 4, 2026
Merged

henry-mosh merged 2 commits into
mainfrom
fix/managed-content-connection-loss

Conversation

@henry-mosh

@henry-mosh henry-mosh commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Three follow-ups to #25 for Autopilot's conditional publishing. 1.6.0 shipped without them. CiteCue does not use conditional publishing yet, so no site is affected today. Ships as 1.6.1.

  • A dropped database connection could be reported as a successful publish. WordPress reconnects and repeats the failed statement. A repeated COMMIT succeeds even though the server already rolled the page back, so the plugin answered 201 for a page that does not exist. It now checks that it is still on the same database session and that the command's receipt was stored. Otherwise it answers 503 citecue_transaction_failed, and the command can be retried.
  • A save hook that saves another CiteCue page during a publish now revokes that page's ownership, like any other save of it. It takes no second lock, so two commands cannot deadlock.
  • The protocol doc was wrong about observations. They hold the page's lock for a few reads, so an editor saving that page at the same moment waits for them.

Checks

  • Four new tests. Three failed before the fix. The fourth guards a case that already worked: a page saved again by its own save hook stays owned.
  • composer lint, phpcs, test:core, test:woocommerce and test:multisite pass on MariaDB 10.11.
  • I also killed the database connection for real, at the COMMIT and at the page insert. Both first answers were 503. After the COMMIT case the retry published the page. After the insert case the retry answered a revision conflict, and an observation returned the page.

🤖 Generated with Claude Code

henry-idingo and others added 2 commits December 4, 2026 18:29
When the database connection drops, wpdb reconnects and sends the
statement again. A COMMIT sent again succeeds on a session that never
began the transaction, so a page the server had rolled back was answered
with 201, and a receipt written on the new session replayed that answer
forever. A command now checks that it is still on the session it began
on, and that its receipt is stored after COMMIT. Otherwise it answers 503
citecue_transaction_failed, which is safe to retry.

A save hook that saves another CiteCue page during a command now revokes
that page's ownership, as any other save of it does. It takes no second
lock, so two commands cannot deadlock.

The protocol doc no longer says an observation never delays an editor's
save: it holds the page's lock for its few reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Version strings, changelog and upgrade notice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@henry-mosh
henry-mosh merged commit c72e163 into main Dec 4, 2026
8 checks passed
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