Skip to content

Keep one record per server and lock the executors in the database - #17

Merged
MoamenEltouny merged 8 commits into
12.xfrom
feat/per-server-records-12.x
Nov 2, 2026
Merged

MoamenEltouny merged 8 commits into
12.xfrom
feat/per-server-records-12.x

Conversation

@MoamenEltouny

Copy link
Copy Markdown
Member

An executor with $servers shared one record across all its servers, so a ONCE executor ran on only one of them, and execute:rollback ran down() wherever it was called. The lock relied on a cache store every server had to share, which the default file store doesn't.

Changes

  • An executor with $servers keeps one record per server: a ONCE executor runs once on each listed server, and an ALWAYS executor runs on each listed server on every deploy. Executors without $servers keep one shared record, as before. A new migration adds the server column and a unique name and server index.
  • EXECUTOR_SERVER (pharaonic.executor.server) names the server, and $servers accepts names next to IP addresses, so $servers works in Docker and other containers. Executor::getServer() and Executor::isServer() expose it.
  • The lock is a reserved row of the executors table instead of a cache lock, so every server that shares the table shares the lock. execute:rollback and execute:fresh take it too, and the model hides the row with a global scope.
  • execute:rollback only rolls back the records this server sees, and never runs down() for an executor limited to other servers.
  • Records are read from the write connection, so a lagging read replica can't make a ONCE executor run twice.
  • New tables have a required batch.
  • The 1.x upgrade migration is removed; the upgrade guide shows how to recreate a 1.x table and keep its records.
  • Docs cover server names, containers, per-server records, the database lock and the 1.x table; changelog Unreleased section.

Compatibility

  • Run php artisan migrate after updating. Records written before it have no server and count as run on every server, so no ONCE executor runs again.
  • A new ONCE executor with $servers now runs once per listed server instead of once for the group. Leave $servers empty for work one server does for all of them.
  • pharaonic.executor.lock.store (EXECUTOR_LOCK_STORE) is deprecated and ignored.
  • A 1.x table is no longer converted automatically; applications that already ran the removed migration keep their converted table.
  • execute:fresh deletes the records instead of truncating the table.

Notes

Port of #15 (released in 10.1.0), meant for 12.2.0. On Laravel 11 and later the model query is typed, so the redundant record check is dropped, and the upgrade guide covers the server column and the database lock when coming from earlier releases of this line.

(cherry picked from commit d282b09)
(cherry picked from commit 4a85703)
(cherry picked from commit deb640c)
(cherry picked from commit 571f07a)
(cherry picked from commit 0caa87c)
(cherry picked from commit 848ca9a)
(cherry picked from commit 9b651f5)
(cherry picked from commit a2a3ef3)
(cherry picked from commit 864898d)
(cherry picked from commit 618e181)
(cherry picked from commit 30c0c7f)
(cherry picked from commit 1a1a0f6)
@MoamenEltouny
MoamenEltouny merged commit ed49593 into 12.x Nov 2, 2026
17 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