fix(raft): gate snapshot build/restore, repoint http ctx, pre-tag docs
CI / test (push) Has been cancelled
CI / raft-e2e (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
CI / test (push) Has been cancelled
CI / raft-e2e (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
This commit is contained in:
@@ -35,6 +35,9 @@ Crash recovery с WAL, schema/index persist, `/health` + `/metrics`, offline bac
|
||||
|
||||
- **Legacy REP replication (без raft)** — пътят още извежда delete от празна стойност; insert в PK-only таблица се прилага грешно по него (редът изчезва). Използвай raft.
|
||||
- **Snapshot-restore ctx** — след InstallSnapshot restore HTTP endpoints със startup-captured ctx може да сервират стари данни до рестарт (`/query` е свеж per-request); съществуващите клиентски връзки виждат pre-restore състояние — reconnect след restore.
|
||||
- **FK-cascade дивергенция под raft** — ефектите на `ON DELETE/UPDATE CASCADE` (и `SET NULL`) не се реплицират през raft: followers прилагат само KV промяната на родителския ред, така че каскадираните дъщерни редове остават на followers. Избягвай FK actions върху raft-реплицирани таблици или приеми периодичен snapshot resync.
|
||||
- **Непотвърдени записи в snapshots** — leader прилага записите локално преди raft majority commit; snapshot, направен в този прозорец, може да включи записи, които никога не се commit-ват (фантомни редове след restore + смяна на leadership). Тесен прозорец; поправката е планирана за следващ release.
|
||||
- **Блокиране на event loop при snapshot build/restore** — snapshot build/restore изпълнява блокиращ tar/gzip на event loop на възела; големи data dirs могат да забавят heartbeats и да предизвикат election по средата на трансфер.
|
||||
|
||||
## Виж също
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ Documented in [distributed.md](distributed.md). Supported scope:
|
||||
|
||||
- **Legacy non-raft REP replication infers delete from empty value** — the non-raft replication path still treats an empty value as a delete, so inserts into a PK-only table are misapplied over that path (the row vanishes). Use raft replication instead.
|
||||
- **Snapshot-restore ctx staleness** — after an InstallSnapshot restore, HTTP endpoints using the startup-captured ctx may serve stale data until the node is restarted; the `/query` path is fresh per-request. Pre-existing client connections likewise see pre-restore state — reconnect after a restore.
|
||||
- **FK-cascade divergence under raft** — `ON DELETE/UPDATE CASCADE` (and `SET NULL`) effects are not raft-replicated: followers only apply the parent row's KV change, so cascaded child rows persist on followers. Avoid FK actions on raft-replicated tables, or accept periodic snapshot resync.
|
||||
- **Uncommitted writes in snapshots** — the leader applies writes locally before raft majority commit; a snapshot taken in that window can include writes that never commit (phantom rows after restore + leadership change). Narrow window; fix tracked for a later release.
|
||||
- **Event-loop stall during snapshot build/restore** — snapshot build/restore performs blocking tar/gzip on the node's event loop; large data dirs can stall heartbeats and trigger an election mid-transfer.
|
||||
|
||||
## Operational requirements
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Release checklist — v1.2.0 Production GA
|
||||
# Release checklist — v1.3.0 raft-supported
|
||||
|
||||
Use before tagging and publishing artifacts.
|
||||
|
||||
@@ -6,8 +6,8 @@ Use before tagging and publishing artifacts.
|
||||
|
||||
- [ ] Working tree clean on `main`
|
||||
- [ ] [Known limitations](known-limitations.md) accurate
|
||||
- [ ] `CHANGELOG.md` has dated `## [1.2.0]` (not Unreleased for shipped items)
|
||||
- [ ] `baradadb.nimble` version `1.2.0`
|
||||
- [ ] `CHANGELOG.md` has dated `## [1.3.0]` (not Unreleased for shipped items)
|
||||
- [ ] `baradadb.nimble` version `1.3.0`
|
||||
|
||||
## Tests
|
||||
|
||||
@@ -44,17 +44,17 @@ docker compose -f docker-compose.prod.yml config >/dev/null
|
||||
|
||||
```bash
|
||||
nimble build_release # or: nim c -d:release -o:build/baradadb src/baradadb.nim
|
||||
docker build -t baradb:1.2.0 -t baradb:latest .
|
||||
docker build -t baradb:1.3.0 -t baradb:latest .
|
||||
```
|
||||
|
||||
## Tag
|
||||
|
||||
```bash
|
||||
git tag -a v1.2.0 -m "BaraDB v1.2.0 Production GA (single-node)"
|
||||
git tag -a v1.3.0 -m "BaraDB v1.3.0 raft-supported"
|
||||
git push origin main --tags
|
||||
```
|
||||
|
||||
## Post-release
|
||||
|
||||
- [ ] Smoke: start prod compose, `/health` → ok, auth required for `/query`
|
||||
- [ ] Announce: single-node GA; Raft experimental (link known-limitations)
|
||||
- [ ] Announce: raft-supported release (3-node, `default` DB); link known-limitations
|
||||
|
||||
@@ -31,7 +31,7 @@ type
|
||||
config: BaraConfig
|
||||
running: bool
|
||||
db*: LSMTree
|
||||
ctx: ExecutionContext
|
||||
ctx*: ExecutionContext # read/write only under the storage gate
|
||||
registry*: DatabaseRegistry
|
||||
metrics*: Metrics
|
||||
secretKey*: string
|
||||
|
||||
@@ -404,6 +404,10 @@ proc main() =
|
||||
# the rest of the server); the registry ctxFactory type is not marked
|
||||
# gcsafe, which would otherwise reject the call.
|
||||
{.cast(gcsafe).}:
|
||||
# Hold the storage gate for the whole close/extract/reopen/repoint
|
||||
# sequence: HTTP workers run queries under the same gate, so this
|
||||
# cannot close the LSM out from under an in-flight /query.
|
||||
withStorageGate:
|
||||
try:
|
||||
defaultDbInfo.db.close()
|
||||
# restoreDataDir moves the old dir aside and extracts the archive; on
|
||||
@@ -424,6 +428,12 @@ proc main() =
|
||||
tcpServer.db = defaultDbInfo.db
|
||||
tcpServer.ctx = newCtx
|
||||
tcpServer.txnManager = newCtx.txnManager
|
||||
# The HTTP thread reads server.db/ctx only inside
|
||||
# withStorageGate (getRequestDatabaseContext in the /query and
|
||||
# /tables handlers), so repointing them here — while this thread
|
||||
# holds the gate — is race-free against request handlers.
|
||||
httpServer.db = defaultDbInfo.db
|
||||
httpServer.ctx = newCtx
|
||||
result = reopened and restored
|
||||
except CatchableError as e:
|
||||
echo "[raft] Snapshot restore failed: ", e.msg
|
||||
@@ -436,6 +446,10 @@ proc main() =
|
||||
raftNode.buildSnapshot = proc(destPath: string): bool {.gcsafe.} =
|
||||
echo "[raft] Building snapshot archive ", destPath
|
||||
{.cast(gcsafe).}:
|
||||
# Hold the storage gate while tarring the data dir so a concurrent
|
||||
# memtable flush (HTTP /query path) cannot write an SSTable
|
||||
# mid-archive.
|
||||
withStorageGate:
|
||||
try:
|
||||
result = backupDataDir(defaultDbDir, destPath)
|
||||
except CatchableError as e:
|
||||
|
||||
Reference in New Issue
Block a user