mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-04 16:34:52 +03:00
fix(database): coordinate migrations and restores across processes (#7322)
Coordinate database maintenance across panel, CLI, node synchronization, and restore paths. - Add cross-process PostgreSQL advisory locks and pinned execution fences; cancel CLI work when its lease session is lost. - Serialize SQLite file replacement with OS-level process locks and stable lock identity. - Drain traffic writers and node-sync work before restore, then resume after migration and validation. - Persist PostgreSQL restore-pending state and recover interrupted restores on startup. - Add regression coverage for concurrent migrations/restores, session-loss fencing, CLI work cancellation, and recovery. Closes #7318.
This commit is contained in:
@@ -85,6 +85,16 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: PostgreSQL maintenance fencing and recovery
|
||||
run: |
|
||||
set -o pipefail
|
||||
go test -p=1 . ./internal/database -run '^Test(PostgresCLIWorkFenceSurvivesSessionLoss|PostgresExclusiveRestoreFenceSurvivesSessionLoss|PostgresPendingRestoreRetriesBeforeServing|PostgresRuntimeMaintenanceReacquiresAfterSessionLoss|MaintenanceAcrossProcesses)$' -count=1 -v | tee /tmp/postgres-maintenance.log
|
||||
passed=$(grep -c -- '^--- PASS' /tmp/postgres-maintenance.log || true)
|
||||
if [ "$passed" -ne 5 ]; then
|
||||
echo "expected 5 passing PostgreSQL maintenance tests, got $passed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: PostgreSQL inbound add orphan cleanup
|
||||
run: |
|
||||
set -o pipefail
|
||||
@@ -238,6 +248,16 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: PostgreSQL database maintenance contention
|
||||
run: |
|
||||
set -o pipefail
|
||||
go test -p=1 . ./internal/database ./internal/web/job -run '^Test(MaintenanceAcrossProcesses|PostgresRuntimeMaintenanceReacquiresAfterSessionLoss|PostgresPendingRestoreRetriesBeforeServing|DatabaseRestoreDrainsAnInFlightNodePoll)$' -count=1 -v | tee /tmp/postgres-maintenance.log
|
||||
passed=$(grep -c -- '^--- PASS' /tmp/postgres-maintenance.log || true)
|
||||
if [ "$passed" -ne 4 ]; then
|
||||
echo "expected 4 passing PostgreSQL database maintenance tests, got $passed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: PostgreSQL inbound migration contention
|
||||
run: |
|
||||
set -o pipefail
|
||||
|
||||
Reference in New Issue
Block a user