Skip to content

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

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

MoamenEltouny merged 6 commits into
10.xfrom
feat/per-server-records-10.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

Meant for 10.1.0. The same changes go to 11.x, 12.x, 13.x and develop afterwards.

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