Postgres engine: scheduler + outbox — schedule (validation triad, the pg-owned @every-only parser, upsert over the schedule table), unschedule, run_schedules (leadership via the engine's lock machinery on __alkstore_scheduler with a per-instance owner token, in-sleep lease renewals, the row-locked FOR UPDATE tick in one pool tx — fire enqueues + boundary advance + soonest read commit together — the 64-boundary catch-up cap with skip-forward, clean stop / Err(LeadershipLost) arms), outbox (validated constructor, enqueue into the derived __alkstore_outbox:{name} with the 60/5/5 stamps + max_attempts override, run_once ack/retry-curve/false over the ordinary claim machinery, no engine-issued heartbeat) (task pg-engine-scheduler-outbox)

This commit is contained in:
glm-5.3-flash committed 2026-10-09 09:53:48 +00:00
1 parent c3591c2d44
commit 77619c5e93
9 files changed
+2547 -78

No files matched your search

+24 -1
View File
@@ -66,7 +66,7 @@ fn table(schema: &str, name: &str) -> String {
/// expiry-delete + insert + read-back race window is closed by the
/// PK constraint — a concurrent grant of the same name either
/// lands first or reads as foreign).
async fn lock_acquire(
pub(crate) async fn lock_acquire(
client: &tokio_postgres::Client,
schema: &str,
name: &str,
@@ -166,6 +166,29 @@ impl std::fmt::Debug for PgLockHandle {
}
}
impl PgLockHandle {
/// The engine-internal constructor (the SQLite twin's
/// `SqliteLockHandle::new_internal` shape): the scheduler's
/// leadership lease on the reserved name — `try_lock`'s entry
/// validation would reject the reserved name, so the engine's own
/// holder builds the handle directly after its own acquire.
pub(crate) fn new_internal(
name: String,
owner: String,
pool: Pool,
schema: String,
closed: Arc<AtomicBool>,
) -> Self {
Self {
name,
owner,
pool,
schema,
closed,
}
}
}
impl Lock for PgLockHandle {
fn name(&self) -> &str {
&self.name