Repository navigation
support replication - #43
Merged
Merged
Conversation
replica-state returns a zero state for a truncated or invalid replica, which replicationStart already treats as “send everything”.
codeboost
added a commit
that referenced
this pull request
Nov 2, 2026
An existing file now opens in the mode its header records: clj1 in Clojure
mode, any other header in compat mode, so files written by other languages
open without passing :mode. New files are still created as clj1 unless
{:mode :compat} is given. An explicit :mode is still checked against the
header of an existing file, for code that relies on one mode.
Add db-mode, which returns :clojure or :compat for an open database.
Old unversioned xitdb-clj files have header ID 0 like Java files and would
now open in compat mode. They are only rejected once xitdb-java's new file
format lands in #43, so this must be merged after it. Until then the legacy
fixture tests pass {:mode :clojure} explicitly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codeboost
force-pushed
the
replication
branch
2 times, most recently
from
November 2, 2026 16:54
f915849 to
a3f0c4c
Compare
xitdb-java 0.46.0 changed the file format, so files written by xitdb-clj 0.5.0 and earlier no longer open. open-database turns the engine's InvalidVersionException into an IllegalArgumentException that says how to migrate, the README upgrade note covers the change, and the version is bumped to 0.6.0. A current-format file with another key hasher, whether its digest has another ID or another size, is refused the same way, and both cases are covered by tests since the legacy fixture stops at the version check. Replication lives in its own namespace, xitdb.replication, which extends databases to clojure.java.io when loaded and keeps xitdb.db lean; its only hook into xitdb.db is the now public lock-file. It gains two small primitives so apps can harden it themselves. replicate! applies an update stream and, unlike with-open around both streams, throws the read error when a connection drops, with the failed commit attached as suppressed; it returns whether the update was a full copy along with the replica state, read while the write lock is still held. can-extend? tells a source beforehand whether a replica's next update extends it or replaces it. A full copy is applied in place, as the engine does it, and the README states the limitations: reads throw while it runs, values read before it must not be used afterwards, an interrupted copy leaves the replica unreadable until the next sync (replica-state describes it as empty so that sync is a full copy again), and only xitdb-clj databases should be replicated into each other. An incremental sync that ends early is truncated back to the replica's committed size, so leftover buffered bytes can't be flushed over data another handle commits later. Nothing is discarded for an update the engine refused, which never wrote anything, or once the engine has begun committing, since its header may already point at the new bytes. compact no longer calls rootCursor to refresh the source's header, since rootCursor doesn't reread it in current xitdb-java; the test is renamed to what it still checks. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
codeboost
force-pushed
the
replication
branch
from
November 2, 2026 17:55
a3f0c4c to
d45b244
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for replication of xitdb files via
io/copy.