When a ZoneTree write becomes visible and when it reaches disk
ZoneTree is a persistent, high-performance, transactional, ACID-compliant ordered key-value database and LSM-tree storage engine for .NET.
At a glance
- What is it?
- ZoneTree gives .NET applications an ordered key-value store with several ways to acknowledge a write. A range scan, a multi-key transaction and a durable commit each answer a different question about the same data.
- Who is it for?
- Choose ZoneTree when an application owns the key layout and needs ordered access in process. Decide which acknowledgements promise power-loss recovery before choosing ordinary or durable commits.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 3 days ago.
- What is it written in?
- Mainly C#, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Choose what a successful write promises
Imagine a .NET application that records a job and maintains a second key for finding that job by due date. Updating the job value answers one question. Publishing both values together answers another. If the application tells a client that the job is safely stored, a third question matters. Would both writes survive a power loss at the moment the acknowledgement was sent? ZoneTree exposes separate APIs for writing a value, grouping writes and synchronising the write-ahead log. A team can decide which promise each operation needs to make.
ZoneTree stores ordered key-value pairs and runs as a library inside the application. The installation command in the README adds its package to a .NET project.
dotnet add package ZoneTreeThe examples discussed here follow the repository at the release-v2.2.0 tag. The package command leaves the version unspecified. Check the version resolved by the consuming project when matching transaction examples to a deployed application. The repository publishes its source under the MIT licence.
Open a tree and decide how to organise the keys
The quick start builds a factory with integer keys and string values, sets a data directory and calls OpenOrCreate. It also keeps a maintainer open alongside the tree. Upsert then sets a value for key 1, and TryGet looks it up by that key. A point lookup is a useful first check on the choice of key and value types, but the order of the keys becomes more important as soon as the application must retrieve several related records.
For example, a job number makes an uncomplicated primary key. A range of job numbers does not automatically mean a range of due dates. If due-date scans matter, the application needs a suitable key layout or an additional index. The storage engine provides the ordering and traversal operations. The application defines which records ought to be adjacent and how to update a secondary entry when a job changes. That decision shapes the reader's query and the writer's consistency requirements.
Where an iterator starts when a key is missing
The iteration guide gives an example with integer keys 10, 20 and 30. A forward seek to 15 positions the next read at 20. A reverse seek to 25 also reads 20 first, for the opposite reason. Each follows the configured comparer in its own direction. This matters when a date or sequence number marks the lower bound for a query but happens to have no matching record. A missing boundary key need not make the whole range empty.
Here is how the README positions a forward iterator before its loop.
using var iterator = zoneTree.CreateIterator();
iterator.Seek(100);The loop then calls Next and inspects CurrentKey and CurrentValue. A range query also needs a stopping condition for the other end. If the result must exclude writes that arrive during a scan, the guide describes snapshot iteration. It cautions that creating a snapshot moves the mutable segment into the read-only layer. Choosing snapshots for every scan under a heavy write load therefore has consequences for maintenance.
Coordinate a read-modify-write or change several keys together
Upsert can replace a single value without first reading it. An increment is different. Two callers can both read an old counter before either writes the new value. For a plain tree the README shows a key lock around TryGet and Upsert. The coordination depends on the other writers participating in that locking convention. Holding a lock around just the final write would leave the earlier decision about the value outside the protected region.
For the job and its due-date entry, the transactional factory opens a tree that can commit both changes together. A transaction reads a consistent snapshot, including range scans. The default Serializable isolation protects the keys and ranges that were read. Snapshot isolation uses a narrower conflict test involving written keys and keys selected for update. The Execute helper can restart the transaction body following a conflict. Consequently a callback that also sends an external message could send it twice. Keep that consequence in mind when deciding where a job notification belongs.
A commit can be readable before it has been synced
The transaction documentation distinguishes visibility from the durability of the underlying log. An ordinary commit makes a transaction visible. With the write-ahead log enabled, a later SyncWalAsync can make earlier ordinary commits durable. There is an interval between those events. A second reader seeing the job during that interval is evidence of visibility inside the live system. Its read does not tell the writer that the disk has acknowledged a sync.
The durable transaction methods take a different order. ExecuteDurableAsync or a transaction's CommitDurableAsync syncs the WAL before publishing the commit to readers. For a service whose acknowledgement promises survival after power loss, that order determines where to wait before sending the response. A rebuildable cache has a different cost to losing recent entries and can make a different choice. The guide explicitly conditions the durable commit guarantee on enabling the log. Selecting no WAL removes the premise behind that guarantee.
Give background merges an owner
Written records move through memory and disk segments. The standard maintainer follows segment movement, schedules normal merges, tracks background work and manages periodic cache cleanup. The maintenance guide distinguishes that work from explicit bottom-segment compaction. It also distinguishes ordinary service operation from a controlled maintenance point, where a caller might request eviction to disk and wait for background threads.
An application can omit the maintainer and use the lower-level maintenance interface, but then the application owns scheduling, retries and coordination. This is a different choice from deciding when a transaction becomes durable. Waiting for a background merge is not the documented substitute for a WAL sync when acknowledging a job. An application that needs SQL joins or a managed database endpoint also has a separate decision to make. ZoneTree supplies ordered storage inside a .NET process. Data modelling, index consistency and the externally visible service remain responsibilities of the application using it.
Editorial conclusion
Choose ZoneTree when an application owns the key layout and needs ordered access in process. Decide which acknowledgements promise power-loss recovery before choosing ordinary or durable commits. For a two-key change that promise belongs to the transaction and its WAL configuration.
Frequently asked questions
Does a ZoneTree transaction become durable as soon as another reader can see it?
An ordinary commit makes the transaction visible. With the WAL enabled, use a subsequent sync for earlier commits or a durable transaction method that syncs the log before making its own commit visible.
What happens when an iterator seeks a key that does not exist?
A forward iterator starts its next read at the next key in comparer order. A reverse iterator uses the preceding key. The iteration guide illustrates both cases with integer keys.
Is a ZoneTree maintainer required?
A tree can operate without the standard maintainer. In that case the application owns merge scheduling, cleanup and background-work coordination through the maintenance interface.
Official sources
Where developers are discussing it
Posts on Hacker News, dev.to and Lobsters that link to this repository, found by our scan of those communities. 0 in the last 30 days; newest first.
- ZoneTree Became FasterHacker News · Oct 24, 2026 · 1 points · 0 comments
Was this useful?