mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-04 16:34:52 +03:00
Merge upstream maintenance fencing into group client paging
This commit is contained in:
@@ -41,7 +41,8 @@ docker compose --profile postgres up -d
|
||||
|
||||
## Migrate SQLite → PostgreSQL
|
||||
|
||||
Move an existing SQLite install to PostgreSQL with the built-in command:
|
||||
Stop the panel, then move the existing SQLite install to PostgreSQL with the
|
||||
built-in command:
|
||||
|
||||
```bash
|
||||
x-ui migrate-db --dsn "postgres://xui:password@127.0.0.1:5432/xui?sslmode=disable"
|
||||
@@ -62,3 +63,35 @@ systemctl restart x-ui
|
||||
|
||||
Whichever backend you use, back it up regularly — see
|
||||
[Backup & restore](/docs/operations/backup-restore).
|
||||
|
||||
## Maintenance locks
|
||||
|
||||
Stop the panel before running `x-ui migrate`. The command waits up to five
|
||||
seconds for the database maintenance lock and reports an error if another panel
|
||||
or CLI process still holds it. In-panel restore drains admitted node polls and
|
||||
queued database writes before switching their database, then resumes work once
|
||||
the restored data is ready.
|
||||
|
||||
PostgreSQL uses advisory lock key `0x3378756964626d74` within the database. The
|
||||
panel uses a dedicated session named `3x-ui-maintenance`. A connection proxy
|
||||
must preserve PostgreSQL sessions for this DSN. After losing the shared runtime
|
||||
session, the panel keeps Xray running and pauses database work until it reacquires
|
||||
the advisory lock. An interrupted exclusive operation is canceled and must
|
||||
restart under a new lease. Its executing connection holds a separate advisory
|
||||
fence so another installation cannot enter while those writes could still commit.
|
||||
|
||||
If an interrupted PostgreSQL restore still needs data migration, startup retries
|
||||
that migration before serving requests. Cooperating installations share the
|
||||
recovery state in `xui_maintenance.restore_pending` in the target database.
|
||||
The first restore creates this schema, which needs database-level `CREATE`
|
||||
permission. Panel backups and restores exclude it. To recover after an
|
||||
interruption, restart the panel or run `x-ui migrate` while the panel is stopped,
|
||||
using the original application schema. Archive restore uses `pg_restore` and
|
||||
`psql` from a client package with the
|
||||
[restricted-mode security fix](https://www.postgresql.org/support/security/CVE-2026-18408/).
|
||||
It stages the decoded SQL in the system temporary directory before applying it
|
||||
in one transaction.
|
||||
|
||||
SQLite uses `.maintenance-lock` and `.maintenance-intent` beside the resolved
|
||||
database file. These paths stay the same while a restore replaces a symlink
|
||||
target. Leave the lock files in place while the panel or any CLI process is running.
|
||||
|
||||
Reference in New Issue
Block a user