an XTDB database should be able to mirror another from its replica log alone
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start with the external-source SPI and TxIndexer, then read core/src/main/kotlin/xtdb/indexer/LogProcessor.kt for the upstream-term fencing invariant. The issue's linked work (#6320–#6323) breaks the approach into separate tasks; clarify the open question about primary databases before taking on the umbrella issue. Done means a mirror consumes only the configured upstream replica log and applies each transaction atomically, including aborted transactions.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
An XTDB database should be able to mirror another XTDB database's user tables by consuming only that database's replica log, with no access to its object store — as a separate database that differs from the upstream in known, listed ways, not as an exact copy.
-
A deployment needs a downstream copy of a database whose object store it can't read
The exact-copy route is a read-only database, which reads the upstream's object store and logs as its own. Without object-store access, nothing can follow an XTDB database today. -
The mirror is an external source whose upstream is another XTDB database's replica log
The external-source SPI already gives it a leader-onlyTxIndexerand an opaque resume token. What's missing is a source that decodes the replica log, plus the core changes listed under Potential approach.
Problem
You can't keep a second XTDB database in step with a first unless it can read the first's object store.
The replica log already carries every transaction as resolved rows, but nothing outside the upstream's own nodes can consume it. A read-only database (Log.Factory.openReadOnlyReplicaLog) also needs the upstream's object store, for blocks, tries and oversized payloads.
How the mirror differs from the upstream
The mirror is its own database that replays the upstream's transactions; anything not derived from those transactions is the downstream's own.
-
Its files on disk differ
The downstream cuts blocks on its own row threshold and flush timer, so block indices, trie and compaction files, per-block statistics (xt/trie_stats) and GC timing all follow its own boundaries. -
Its log positions differ
Replica- and source-log message ids, term ids and offsets are the downstream's own, as is its external-source token. -
Its tx ids differ from the upstream's; the upstream's is carried in
user_metadata
Upstream tx ids are source-log message ids — sparse, with the log epoch in the high bits. The downstream assignslatestCompletedTx.txId + 1(TxResolver), so an upstream tx id, basis or await token means nothing downstream. #6323 would let the mirror keep the upstream's. -
Its system times match the upstream's, except when mirroring the primary database
The upstream makes system times strictly increasing before they reach the replica log, so the downstream's smoothing (lct + 1µs,TxResolver) never fires on them. The exception is the primary's attach/detach operations, which take the raw log timestamp unsmoothed, so a following transaction can be moved forward. -
It lags the upstream
Everything, erasures included, appears downstream only once replayed. Erased data stays readable downstream for that long, and its physical purge then follows the downstream's own compaction. -
It doesn't carry the upstream's
xtschema
xt/txsis the downstream's own, one row per mirrored transaction, carrying the upstream'scommitted,user_metadataanderror.xt/role_membership(GRANT/REVOKE) is skipped, so the upstream's role grants don't cross over. Attach/detach operations aren't applied, so a mirror of the primary attaches no databases. -
An aborted transaction's error is the deserialised form
It arrives as transit (ReplicaMessage.ResolvedTx.error), not as the original exception. -
Its users, authorisation and settings are the downstream node's own
Users and passwords live in authn config rather than in tables, so nothing about them is mirrored. The same goes forpg_user/pg_roles, the database name and metrics.
Invariants
-
The mirror never produces to the upstream's replica log
Leader election lives in the replica log itself: aLogProcessorwhose poll comes back empty appends aNoOpclaim (core/src/main/kotlin/xtdb/indexer/LogProcessor.kt). A reader that appends anything takes part in the upstream's election. -
A record from a deposed upstream leader is never applied
The replica log can carry records from a term that has already been superseded. Applying them diverges the mirror from what the upstream's own followers hold.LogProcessor.admitenforces this for followers and isprivate, so the mirror needs the same fence: droptermId < highest, sequencetermSeq, and void the rest of a term from its first gap. -
One upstream transaction becomes exactly one downstream transaction, aborted ones included
A torn transaction would be visible to downstream readers at some basis, breaking the upstream's atomicity guarantee. An aborted one is mirrored as aborted, so the downstream'sxt.txslines up one-to-one with the upstream's.
Potential approach
goal: the downstream database holds the upstream's user-table history, and its transaction log, from the point it started following, and reads nothing from the upstream but its replica log.
- A mirror source applies each upstream transaction as one downstream transaction — #6320
- A mirror started on a copy of the upstream's object store resumes from the copy's latest block — #6321
- A mirror refuses to apply a topic other than the upstream it was configured for — #6322
- A transaction the upstream offloaded to its object store reaches the mirror — #6324
A transaction too large for the log is written under the upstream'soversized/prefix, with anOversizedMessageleft in its place, which the mirror can't read. - idea: An external source can keep its upstream's tx ids — #6323
Not needed for the goal: the upstream's tx id travels inuser_metadata.
Out of scope
-
Loading upstream history that predates the mirror
Without a copied object store, the mirror starts from whatever the upstream's replica log still retains. Retention only promises records at or after the upstream's latest block boundary (allium/log-processor-lifecycle.allium). Copying the object store is the supported way to bring history across (#6321). -
Filtering user tables
The mirror skips the upstream'sxtschema and nothing else. -
Resuming after the upstream's replica log is truncated past the mirror's token
This is the general external-source case, tracked in #5918.
Alternative approaches
- Cutting downstream blocks in step with the upstream's
BlockUploaded: reasoned against, 2026-10-30
Rough goal: identical block indices and boundaries on both sides.- con: the block contents differ anyway — the downstream's own
xt.txsrows and skippedxttables — so the two stores' files can't be swapped. - con: the copied-store resume (#6321) doesn't need aligned boundaries, because the next downstream cut is simply the copy's latest block + 1.
- con: it needs a
TxIndexer.cutBlock()(two-way door) and an SPI opt-out of row-threshold and timeout cutting (one-way door). The opt-out hands the source responsibility for live-index memory and for log-retention liveness (#5778).
- con: the block contents differ anyway — the downstream's own
- Lingua principale
- Clojure
- Stelle
- 3.1k
- Fork
- 193
- Merge medio
- 1g 8h
- PR unite (30g)
- 73
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di xtdb/xtdb
-
unshaved-yak
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
sql unshaved-yak
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
flaky
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
metrics
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
.Needs Triage .Team/UXWest Misc/Accessibility Priority:P3 Type:New Feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
metabase/metabase#88153 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
editor-code-assistant/eca#717 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
nasa/Common-Metadata-Repository#2544 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100