Document sync_interval for deb/alpine and test interval changes
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful

- add sync_interval to the github_deb/github_alpine docs and the caching field table
- apply the created_at slot gate only when no sync state row exists
- test 0<->N interval changes, the insert-only gate and a negative sync_interval on update
This commit is contained in:
2026-10-25 19:30:28 +11:00
parent ee55ef3fcd
commit 905c529d61
7 changed files with 129 additions and 7 deletions
+4 -2
View File
@@ -50,7 +50,8 @@ func (db *DB) ReleaseGitHubSyncLease(ctx context.Context, remoteName, owner stri
// next_retry_at, or, with no retry pending, the remote was never synced or was
// last synced before the current slot (interval set) or longer than freshness
// ago (otherwise). With interval set, slots start at phase past each multiple
// of interval and a remote created inside the current slot waits for the next.
// of interval and a remote created inside the current slot with no state row
// waits for the next.
// Slots are computed from the DB clock so replicas agree whatever their own
// clocks say. A zero freshness and interval (prime scans) ignores the recency
// gate but still honours a pending retry's backoff. The returned etag is the
@@ -63,7 +64,8 @@ func (db *DB) claimSyncLease(ctx context.Context, table, remoteName, owner strin
SELECT r.name, $2, now() + make_interval(secs => $4)
FROM remotes r
WHERE r.name = $1
AND ($5::float8 <= 0 OR COALESCE(r.created_at, '-infinity') < `+slot+`)
AND ($5::float8 <= 0 OR COALESCE(r.created_at, '-infinity') < `+slot+`
OR EXISTS (SELECT 1 FROM `+table+` e WHERE e.remote_name = r.name))
ON CONFLICT (remote_name) DO UPDATE
SET sync_lease_owner = $2,
sync_lease_expires = now() + make_interval(secs => $4)