Correctness · v2.1.12
Verification
This page records what is claimed, what has been checked, how, and what has not. Bounded model checking is evidence about a model, not a proof of the Rust implementation or of every deployment.
What is claimed#
For one database, under the storage assumptions below:
- Durability and one history. Every acknowledged transaction, together with the exact sequence of transactions before it, can be reconstructed from the bucket alone. All acknowledged histories are therefore prefixes of a single sequence: nothing acknowledged is lost, reordered or forked, whatever servers crash, pause, race or are replaced.
- Linearizable reads. A
strongread reflects every transaction acknowledged before the read began. - Safe collection. No server deletes an object that the current owner, or any later owner, needs.
- Final deletion. Once any server has concluded that a database is deleted, no server acknowledges anything for it again. A deletion that did not complete leaves the database either intact or deleted, never in between.
Assumptions#
- Storage provides read-after-write consistency for PUT, DELETE, GET, HEAD and LIST, and never exposes a partial object. It may be arbitrarily slow, fail any request, and lose any response. A listing reports each key as it was at some moment during the listing, in key order.
- Servers stop without warning, pause for any length of time and resume, and run with arbitrary relative speeds. They do not run corrupted code or forge each other's objects: all servers of a deployment are trusted with the bucket.
- Uploads a server has sent may arrive late, more than once, and after the server has crashed.
- Clocks are not assumed to agree, or to be correct at all. Token expiry is the only place a clock is read, and it affects authorization only.
- Membership may be wrong or disagree between servers.
The model#
spec/DurableDb.tla specifies creating a database, taking ownership, committing, linearizable reads, requests that store nothing (a transaction refused by a check, and the retry of one already applied), checkpointing, collection and deletion for one database, as atomic steps on a store of claims, manifests, frames and the tombstone. The store starts empty. Writers crash at any step. Any upload ever sent may arrive at any later time, any number of times, including after its object was collected. In the configuration LateDeletes, so may the DELETE a collection sends, after its sender crashed, released the database or was revoked.
Five invariants are checked in every reachable state:
| Invariant | Meaning |
|---|---|
Durable |
Every acknowledged history is a prefix of what a reader reconstructs from the store, unless the database was deleted. |
FreshReads |
No checked read missed a transaction acknowledged before it began. |
OwnerIntact |
The newest checked manifest of a writer whose claim still stands has not been deleted. |
Final |
Once a writer has concluded that the database is deleted, no writer is serving with a claim that stands. |
Once |
A transaction that a client sent more than once is in the database once: in what any writer holds, and in what a reader reconstructs from the store. |
scripts/check-model.sh # about five minutes; capped at 2 GiB heap, four workers and ten minutes a configuration
Results (TLC 2.19; the first three 2026-11-14, and again with the same counts on 2026-11-17, when the model gained requests that store nothing; Retries and LateDeletes 2026-11-17), each an exhaustive search with no violation:
| Configuration | Bounds | States generated | Distinct states | Depth |
|---|---|---|---|---|
DurableDb |
2 writers, epoch numbers up to 2, 2 transactions, no deletion | 27,663,022 | 3,585,296 | 61 |
Deletion |
2 writers, epoch numbers up to 2, 1 transaction, deletion at any time | 23,717,105 | 4,110,075 | 67 |
DeepDeletion |
2 writers, epoch numbers up to 2, 2 transactions, deletion at any time | 479,947,461 | 67,082,438 | 74 |
Retries |
2 writers, epoch numbers up to 2, 1 transaction sent again and refused at any time, no deletion | 5,194,549 | 658,613 | 60 |
LateDeletes |
2 writers, epoch numbers up to 2, 1 transaction, a collection's DELETE arriving at any later time, any number of times, no deletion | 7,257,541 | 967,385 | 59 |
The configurations of one transaction exist because deletion, requests sent again, or deletes that arrive late, with two transactions, is a much larger state space. spec/DeepDeletion.cfg is the first combination; spec/DeepRetries.cfg, two transactions sent again and refused, is the second, and is not part of the default run either: on 2026-11-17 it did not end in ninety minutes on four cores, after 1,285,272,535 states generated, 111,378,787 of them distinct, to depth 57, with 11.7 million still to explore and no invariant violated. That is a partial search, not a result like those in the table. Both negative controls of requests fail at the bounds of Retries. LateDeletes adds no rule, and so no control: what a collection deletes, no later epoch needs, whenever the DELETE arrives. DeepDeletion is not part of the default run, because it takes nineteen minutes where the others take five together:
TLC_TIMEOUT=3600 scripts/check-model.sh DeepDeletion
For a search of this size TLC reports how likely it is that two distinct states had the same fingerprint and one was therefore not looked at: 0.0015 by its calculation, 0.00019 by the fingerprints it saw. An earlier version of this page said that a run of this configuration had been stopped after 24 minutes and 92 million distinct states. With the model and the configuration as they are in the repository it ends with fewer states than that, so that run was not of this model; which it was of is not recorded.
The epoch number a writer chooses is unconstrained in the model (any unused number), so safety does not depend on the hint the implementation uses.
Negative controls#
Each protocol rule is a switch in the model. Turning one off must produce a counterexample; if it did not, the model would not be testing that rule. All thirteen are refuted:
| Rule turned off | Configuration | Violated |
|---|---|---|
| Acknowledge only after a claim check that began after the frame was stored | UnsafeAckWithoutCheck |
Durable |
| Withdraw when a higher claim is listed | UnsafeIgnoreHigherClaim |
OwnerIntact |
| Withdraw when a higher epoch already has a manifest | UnsafeIgnoreHigherManifest |
Durable |
| Delete lower claims before reading manifests and frames | UnsafeReadBeforeRevoke |
Durable |
| Collect only after a claim check that began after the manifest was stored | UnsafeCollectWithoutCheck |
Durable |
| Never use a claim whose upload may still be in flight | UnsafeRetriedClaim |
OwnerIntact |
| Never delete the own claim while an own manifest upload may still arrive | UnsafeReleaseWhileSending |
Durable |
| After revoking, give the claim back only when a higher epoch outranks this one | UnsafeGiveBackAfterRevoke |
Durable |
| Expose recovered state only after a claim check that follows the first manifest | UnsafeServeBeforeCheck |
Durable |
| Write the tombstone only after a claim check that began after a manifest marked deleted was stored | UnsafeTombstoneWithoutCheck |
Final |
| Remove a deleted database's objects only once the tombstone is stored | UnsafePurgeBeforeTombstone |
Final |
| Answer a request that stored nothing only once all it was judged against is acknowledged | UnsafeAnswerBeforeAck |
Durable |
| Recognize a retry against all the writer holds, transactions recovered from earlier epochs included | UnsafeRetryAgainstOwn |
Once |
What the model leaves out#
- Tables are folded into the manifest's state. Their collection follows the same rule as superseded manifests, which is modelled, with one exception that is not: the table a merge was uploading when its database was released, deleted or closed is deleted by that upload once it ends, whatever claim its server holds then (since 2.1.10). No manifest lists such a table or can come to: only one of its own epoch could, and its merge has ended. So no state the model holds refers to it, and deleting it removes nothing a reader could be sent to.
- Checks and retries are abstract. A transaction refused by a check, and the retry of one already applied, are modelled as a request that stores nothing and is judged against the writer's whole state, writes on their way included, as the implementation judges them; what the check compares, a version, a range or the revision, is not. A retry is recognized against all the writer holds, as the implementation's receipts are part of the database; that it forgets a receipt after
receipt_windowrevisions, after which a retry is applied again, is not modelled. A writer has one such answer pending at a time, and only one judged against writes still on its way is modelled: an answer about a state acknowledged already says nothing new. - Only a collection's deletes arrive late. In
LateDeletes, the DELETE a collection sends, including the sweep of what earlier epochs left, takes effect at any later time, any number of times, also after its sender crashed or released the database and another owner took it; since 2.1.6 a collection gives way to a release in the middle of a purge, and since 2.1.11 the sweep does, leaving such requests on the wire. A revocation's DELETE of a claim, a release's of its own claim, and the purge of a deleted database are still atomic steps. The argument that a late one is harmless is informal: each is sent only for an object its sender was entitled to remove for good, and the only object whose reappearance would matter, a claim, is uploaded once. The chaos test does inject such deletes. - Only safety is checked. That some server eventually makes progress is not.
- The bounds are small. Two writers, two epochs and one or two transactions cover every interleaving of one takeover with commits, a flush, collection, a deletion and late uploads, not longer chains.
- Nothing connects the model to the Rust code except that the code is written to follow it step for step and the tests below.
Tests of the implementation#
| Test | What it does | Result |
|---|---|---|
tests/chaos.rs |
Three nodes share a store that delays every request, drops 4%, applies another 4% while reporting failure, and applies 3% up to 1.5 s after reporting failure. Its purges remove one key at a time and can stop partway. Nodes crash without releasing, are released at random, and stale owners keep running. Checked: every acknowledged append is present at its revision; a compare-and-set counter equals the acknowledged increments; no linearizable read returns a revision older than a prior acknowledgement; a released database leaves no claim and no log. Then six databases are deleted under the same faults, by a node that was cut off and replaced, by nodes that stop after a few writes, and by repeated requests; no write is acknowledged once any client was told the database is gone, and only the tombstone remains. | 200 seeds pass (CHAOS_SEEDS=200, release build, 105 s), and pass again in sixteen simultaneous runs each held to 40% of one CPU (systemd-run --user --scope -p CPUQuota=40%). Three run on every cargo test. A seed that has not finished after five minutes is reported by number and the run is stopped. |
tests/interleavings.rs |
Chosen schedules, built by holding or failing single storage requests: a takeover that fails after revoking, a takeover during a deletion, an unconfirmed deletion, an interrupted cleanup, a lookup that overlaps a merge, a refusal that overlaps an uncommitted write, a database that was never created, deletions while a flush is stuck, a flush that falls due during a merge, a database waiting for its turn to merge, a release during a merge, a merge that fails, an empty disk cache read all at once, a spare upload that the store declines, a deletion and a release while a collection waits for a purge, a collection whose purge the store does not answer, a round of housekeeping while a release waits for the store, writes that wait for a merge the quota asked for, a merge for the quota that made no room, a database that falls idle while it merges, a table in use that is not put out of the disk cache for another, a table that is read a block at a time until reads have had a sixteenth of it, tables that leave the disk cache with their manifest, a merge that keeps none of the tables it reads, a fetch for the disk cache that fails, a scan that reads ahead and not past its end, sixteen scans that read ahead while a seventeenth does not, a damaged copy in the disk cache that another reader discarded first, a merge whose tables, and those of a flush it gives way to, take the room of those it has read and not of those it is coming to or has stored, a merge of tables in the disk cache that leaves its result and another database's table there, a merge that outlasts the time after which a table counts as unread, a fetch that arrives when its table has left the manifest, an index that reads ask for and blocks that want its room, a merge that is due when a database is opened, a merge that gives way to merges of what was flushed behind it, and to none larger than what it has stored, nor when the runs are few, a merge that another gave way to and that gives way to no merge, what falls due during it, the turns to read ahead of a merge that waits, a release while a merge waits for another, writes while a merge would leave too many runs and while a database waits for its turn to merge, a merge that merges behind it without a flush, a database whose merge failed, one opened with too many runs, a merge that waits out a store that fails for a while and not one that fails for good, a request's read that gives up meanwhile and does not wait for the merge's, what a merge gave way to that failed for a while and for good, a release, a deletion and a takeover while a merge waits for the store, a release while its read is under way, a merge that gives its turn to a database that waits for one and waits for one again, flushing and taking writes meanwhile, holding no index, and counting its runs again once it has the turn, a merge behind a merge that waits for no turn, a release and a deletion that do not wait for a merge's upload, which deletes what it stored, a merge that uploads its tables one attempt at a time, and a merge not begun once a release has, nor after the flush a merge for the quota makes first. | 74 pass. |
tests/engine.rs |
Transactions, checks, retries, crash recovery, takeover, stale owners, flush, merge, collection, quota, deletion, disk-cache corruption, configuration changes made at once, a read that runs out of room, merges into tables of limited size, more table index than the cache holds, the keys many databases remember, 96 databases in use while they are tended 2,000 times, a round of housekeeping that panics, a round that does not end, a database at its quota whose keys were deleted, written over, or can all still be read. | 24 pass. |
tests/storage.rs |
The S3 binding against a stand-in that keeps versions, pages its listings and verifies every signature: awkward keys, status handling, listings cut short, purges across page boundaries and interrupted. A purge removes a page of versions with one request; a request of a purge that is not answered is sent again twice; a removal that was carried out and not answered is not a failure when it is sent again; a version the bucket says it did not remove is asked for again, and is a failure if it is still there after that; a bucket that refuses the request, in five ways, gets one for each version and is not asked again; a key that XML cannot name is removed alone; a stand-in that keeps no versions and has no request that lists them is purged by key, and asked for its versions once. The stand-in answers a listing of versions as Google Cloud Storage does unless it is asked for Amazon's shape, and refuses a request with an unsigned x-amz or x-goog header, with headers signed out of the order of their names, or with a wrong Content-MD5. It refuses reads as a store that is asked too much does and goes on taking listings and changes: eight reads are sent, then none of forty, then one of twenty once the two seconds it asked for are over, and all of them when one has been taken, while every listing and change is sent throughout. It refuses listings and goes on taking reads: eight listings are sent and then none, a purge's among them, while every read between them is sent and answered. The directory store against the in-memory one. One order of directory names on all three. |
19 pass. 28 faults put into the purge one at a time each fail a test, and so do 39 put into what holds requests back from a store that refuses them, here or among the unit tests of src/store/s3.rs (findings 38 and 39). |
tests/http.rs |
The documented API against a real server process, including a killed server. | 8 pass. |
tests/tenants.rs |
What one caller can do to the others, against servers whose memory budgets can be read: stalled bodies with and without a token, a database that fills its part of a budget, results that wait to be read, a caller that stops reading, results relayed by another server, requests of very many items, paths a client would rewrite, a forged relay header, silent connections at the connection limit, readiness probes in bulk, shutdown with a request in flight. | 14 pass, and each alone on 15% of a processor. |
tests/cluster.rs |
Up to three server processes on one store: routing to one owner, a killed owner, a graceful handover, a joining node, a contended counter while nodes are killed and restarted. | 5 pass. |
tests/bucket.rs |
On a real bucket: the storage contract including versions, delete markers and the order of directory names; read-after-write (8 workers × 12 rounds, each PUT and each DELETE followed at once by HEAD, GET and LIST); a purge of 1,041 versions across two listing pages while the deleted key that straddles them is polled; sixty versions of keys with &, < and a space removed with one request, which Backblaze must take; the engine with a takeover, a release and a deletion. |
5 pass on Backblaze B2, with native uploads and with PutObject only, and on the five buckets of scripts/test-stores.sh. A request that fails on its way is sent again, as the engine sends it (findings 29 and 34). |
durable-db bench --workload ledger |
Transfers between accounts, each with a log entry in the same transaction; afterwards the balances must sum to the starting total and the log must hold exactly the acknowledged transfers. | 11,774 transfers verified on three servers sharing a directory, and 4,902 on three servers sharing a B2 bucket, each while one server was killed and one terminated. |
scripts/soak-memory.sh |
One server with the flags of the Kubernetes manifest on a local directory, in a scope limited to 1 GiB without swap and four CPUs. Three loads of a minute each with values that do not compress: half commits of 16 KiB over 4 databases, commits over 256 databases, strong reads from 512 clients. The server is killed if it passes the limit. Then the script kills it in the middle of the second load run again and starts it again, so that 256 databases are opened at once while they are written to. | 580 MiB at most in one run of 2.1.7, and 541 MiB for the server that was started in the first one's place. 582 to 596 MiB in three runs of 2.1.6, and 540 to 563 MiB for the second server. 575 to 591 MiB in six runs of 2.1.5, two of them made between those of 2.1.6; 599 MiB with ten minutes of each load, in which memory was level (performance). 582 and 590 MiB in two runs of 2.1.4. With 2.1.1 it was 621 MiB, and 618 and 659 MiB with 2.1.0, on servers that may have stopped their housekeeping during the second load (finding 36). No request failed in the three loads. How many of the first load's requests are told to wait is not the same from one run to the next: none to 8% in ten runs of 2.1.5, none to 6% in ten of 2.1.6 and four requests at most in four of 2.1.7, runs of that load alone among them; none in two runs of 2.1.4, 0.4% in one of 2.1.1 and 1.7% in one of 2.1.0. Earlier versions of this page gave up to 0.7% for 2.1.5, from its first four runs. |
scripts/test-kubernetes.sh |
The shipped manifests on a three-node kind cluster backed by Backblaze B2. The ledger runs through the Service while the autoscaler adds pods under CPU load, a pod is force-deleted, and the autoscaler removes pods. | Eighteen runs, four with 2.1.0, seven with 2.1.1, two with 2.1.2 and one each with 2.1.3, 2.1.4, 2.1.5, 2.1.6 and 2.1.7, each scaled 2 → 5 → 2 with a pod force-deleted. Every ledger verified: 12,026 to 25,965 transfers in 240 s, the fewest in three runs made in an afternoon hour when the bucket was slower. Of 9 to 13 million session reads sent meanwhile without retries, 0 to 110 failed and 0 to 124 were told to wait. The read rate moves by a third from run to run with either release, and more than half the reads are relayed between pods (performance). |
scripts/test-upgrade.sh |
Three servers of one release on one directory, replaced by the next one at a time while the ledger runs through all three; then one goes back to the old release and forward again, so that each version takes over databases the other wrote. | From 2.0.0 to 2.1.0: 171,474 transfers verified. From 2.1.0 to 2.1.1: 152,215. From 2.1.1 to 2.1.2: 152,861. From 2.1.2 to 2.1.3: 142,809. From 2.1.3 to 2.1.4: 155,916. From 2.1.4 to 2.1.5: 152,708. From 2.1.5 to 2.1.6: 155,642. From 2.1.6 to 2.1.7: 160,943. |
scripts/test-stores.sh |
Three S3 servers in containers on the desktop, each held to 1 GiB and two CPUs: a community build of MinIO (pgsty/minio, RELEASE.2026-08-04) and RustFS 1.0.5, each with a bucket that keeps versions and one that does not, and Garage 2.5.0, which keeps no versions and has no request that lists them. The bucket tests on each bucket; then a ledger through three servers on the store for 75 s while one is killed, one is stopped and one is killed again, each replaced at once. |
With 2.1.6: the bucket tests pass on all five buckets, no store refuses the request that removes many versions, and every ledger verified: 45,326 transfers on MinIO, 13,061 on RustFS and 73,710 on Garage, with no failed purge. With 2.1.7: the bucket tests pass on all five buckets, and ledgers of 50,307, 13,175 and 73,396 transfers verified, with no failed purge. Each store was one process on the desktop's disk: this says that its answers are understood and that the protocol holds on them, not how fast it is or what it does across several machines. |
scripts/soak-kills.sh |
Three servers on one directory, each held to 1 GiB and two CPUs, under a ledger of 16 clients over 8 databases. Every ten seconds one of them, each in its turn, is stopped and started again: killed outright three times in four, told to stop the fourth. | With 2.1.5, thirty minutes: a server was stopped 157 times, 118 of them killed, and a ledger of 1,939,925 transfers verified. No server used more than 187 MiB or had more than 44 files open, and none panicked. With 2.1.6, ten minutes: 52 stops, a ledger of 586,716 transfers verified, 118 MiB and 43 open files at most. With 2.1.7, ten minutes: 52 stops, 598,473 transfers, 116 MiB and 39 open files. This is one desktop and one directory: it says that half an hour of stops loses nothing, applies nothing twice and leaves nothing to pile up in a server, and nothing about a network between machines. |
scripts/test-refusals.sh |
One server on the same build of MinIO in a container, behind an nginx that passes every request on, and for the middle twenty seconds of a sixty-second ledger answers every PUT, POST and DELETE as a store that is asked too much does: 503 SlowDown with Retry-After: 2. Reads are passed on throughout. |
With 2.1.4, in three runs, the store refused 1,112 to 1,168 changes in the twenty seconds: 206 to 224 in the first second and about 140 in every second after it. With 2.1.5, in three runs, 23 to 36: 18 to 31 in the first second, more than eight because requests sent before the eighth refusal was answered are refused as well and one that was taken late lets eight more be sent, and at most one in any second after it. A change was taken 0.3 s after the refusal ended, and 2.3 s after one of ten seconds; four seconds is the most the rule allows. Every ledger verified, 15,231 to 24,036 transfers. Commits waited the twenty seconds out and were then acknowledged: a database gives its storage thirty. With 2.1.6, in two runs, 13 and 37 changes were refused, at most one in any second after the first, and ledgers of 21,668 and 21,969 transfers verified. With 2.1.7, in two runs, 29 and 23, and ledgers of 16,675 and 21,954 transfers. |
scripts/soak-bucket.sh |
One server with the flags of the Kubernetes manifest, held to 1 GiB and four CPUs, on the same build of MinIO in a container held to 4 GiB and four CPUs. 256 databases are written for twenty minutes by a client each, with 1 KiB values that do not compress, and are then deleted one after another. The server may not be killed or panic, and no round of its housekeeping may run for thirty seconds. | With 2.1.6: 2,110 commits a second and none failed; 582 MiB at most, and 416 to 581 MiB from the third minute to the twentieth; 1,148 of 17,593 purges failed, for listings that MinIO took longer than twenty seconds over, and were made again later; the server held nothing back and failed no request for one it did not send; the 256 deletions took 257 s and none failed, the slowest 143 s. With 2.1.7: 2,232 commits a second and none failed; 567 MiB at most, and 422 to 533 MiB from the third minute; nothing held back and no request failed unsent; 2,278 of 13,251 purges failed for listings that were not answered, which is one in six where it had been one in fifteen, and the 256 deletions, each of which lists what its database has, took 899 s, the slowest 229 s; none failed. The code that purges and deletes is that of 2.1.6. With 2.1.5 the same run had reads held back eleven times and 16 of the deletions answered 503 (finding 39). The store was one process on the desktop that loaded it: this says what a server does on a store that is slow over its listings, and gives no figure for a store. |
scripts/soak-size.sh |
One database filled to a size with values of 4 KiB that do not compress, through one server with the flags of the Kubernetes manifest, held to 1 GiB and four CPUs. The server is killed. A second, with an empty cache, opens the database, is read, scanned and written over, and then has the database's quota set under what it holds, so that a write waits for a merge of everything. It is stopped, a third opens the database, and the database is deleted. No server may be killed or panic, the write at the quota must be taken, and no round of housekeeping may run for thirty seconds. | With 2.1.7: 4 GiB and 16 GiB on a local directory, 4 GiB on MinIO and 1 GiB on Backblaze B2. No request of any load failed. The servers used 422 to 495 MiB at most. The writes at the quota were taken after 36 s, 168 s, 67 s and 525 s. The count of what each load read from storage is how finding 43 was found. Figures in performance. |
What these checks found#
The chaos test found three defects in the first implementation of this protocol, each within seconds. They are listed because they show what the checks are able to catch.
- After a failed takeover the server deleted its claim although its manifest upload could still arrive. A lower epoch could then serve, and the late manifest would hide its acknowledged writes. The model forbade this step; the implementation had not followed it. It is now the
UnsafeReleaseWhileSendingcontrol. - State recovered at takeover, including transactions the previous owner stored but never acknowledged, was visible before a claim check confirmed it. Now the
UnsafeServeBeforeCheckcontrol. - A stale owner could answer "conflict" from old state, so a client concluded that a transaction it had in fact committed was not applied. Refusals now wait for a claim check.
Release 2.0.0 was then reviewed in three parts (the engine, the storage layer, and the HTTP and tenant boundary) by automated reviewers instructed to break it and to prove each finding with a failing test. What they confirmed in the engine and the storage layer, all fixed since, each with a test that fails on the old code:
- Deletion was outside the protocol. The owner checked its claim and then wrote the tombstone. A server that took over between the two served the database and acknowledged writes, and the tombstone then arrived and deleted it. Deletion is now a manifest settled by a claim check that follows it, modelled, with the
UnsafeTombstoneWithoutCheckandUnsafePurgeBeforeTombstonecontrols. - A takeover that failed after revoking gave its claim back. The revoked epoch's first manifest could still arrive. A third server could then choose a number below it, serve, and have its acknowledged writes hidden when that manifest landed. Now the
UnsafeGiveBackAfterRevokecontrol. - A purge could make a revoked claim readable again on a bucket that keeps versions, when a listing page ended between the claim's delete marker and the version under it. On Backblaze B2 the old code showed the key during the purge;
tests/bucket.rsreproduces that arrangement. - A listing page that held nothing but said there was more ended the listing, so a claim could be missed at takeover. Whether a provider sends such a page was not established; the client no longer depends on it.
- Two directory stores on one directory could exchange temporary files when they shared a process id, as two containers on one volume do, and acknowledge an object holding another's bytes.
- A lookup that overlapped the owner's own merge reported the database lost and closed it. An inverted range stopped the writer. A refusal could report a conflict with a write that was never committed. A crafted table footer panicked instead of reporting damage. Keys that are not UTF-8, accepted only by the library interface, became unreadable once flushed; they are now refused.
The same review of the HTTP and tenant boundary confirmed the following, also fixed, each with a test in tests/tenants.rs, tests/engine.rs or tests/interleavings.rs. Undoing any one of the fixes makes its test fail; that was checked for each.
- Memory was committed to callers who had not shown a token. A request's body was budgeted and read before its token was checked, a request with no body was charged for the largest one, and nothing limited how long a body, a request head or an unread response could take. A few hundred connections that sent nothing could hold the whole budget and refuse every other caller. The token is now checked against the database in the path first; bodies and results are reserved for exactly, with a quarter of each budget per database; and every phase of a connection has a time limit.
- A read was limited after it had been put together. One request could name thousands of scans over deleted keys still in memory, or thousands of large values, and have all of it gathered before being told it was too much. A request's arrays were likewise parsed in full before being counted. Both are now counted as they grow.
- A response nobody read stayed in memory for as long as the connection did. It is now part of the result budget until it is written, and the connection is closed when the client takes nothing for 30 seconds.
- A stored value kept its whole request alive. A small value sent in a large body pinned that body in memory until the next flush, uncounted. Values are now copied out of the request.
- Deletions were exempt from back-pressure, so a database could fill memory with them while a flush was behind.
- Two configuration changes made at once could lose one, for instance a token revocation. Changes are now applied in the writer, to the configuration as it stands.
- A relayed path could be read differently by the next server, because the HTTP client normalizes
.and..segments and backslashes. Access was still checked there, so no data crossed tenants; such paths are now refused by every server. Any caller could mark a request as relayed, which made a server take over a database the caller had a token for. The mark is now a proof made with the signing key. - Logs named databases. They now carry a tag derived from the name. A token lifetime near the largest number wrapped around.
/readyz, which anyone may call, asked storage on every call.
The engine was then read for whatever it holds in memory that no flag limited, so that the memory a server needs could be stated. Found and fixed, each with a test that fails when the fix is undone:
- A merge built its whole result in memory, and so needed as much memory as the database it merged. A merge now writes tables of 32 MiB, one at a time.
- Every table kept its index for as long as its database was open. An index can be as large as its table. Indexes are now held by the cache, within
--cache-bytes. - The keys remembered for range checks were limited in number only: 100,000 keys of the largest size are 112 MiB, for each open database that wrote that many. They are now limited in bytes, for a database and for the server.
- An empty disk cache fetched every table that was read, whole, all at once: after a restart, as many tables in memory as were being read. Two are fetched at a time.
- A database waiting for its turn to merge stopped flushing, so two long merges of other databases could make it refuse writes. A merge held up its own database's flushes and its release until it was done. A waiting database now goes on flushing, and a merge gives way between two of the tables it writes.
A server from before these changes ignores what a manifest says about runs and reads each table on its own, which gives the same answers.
- The first version of the fix for 22 asked for a new turn as soon as a merge failed, and was given it at once: a merge that could not reach storage was repeated without pause. The 200 chaos seeds passed all the same. One run made while the machine was busy with other work did not end, and that was the only sign. It was reproduced by holding the test to a fraction of a CPU, found in a core dump, and fixed: a failed merge now waits for the database's next write. Two things follow. A chaos seed does not fix the whole schedule, because the engine reads the wall clock for its storage deadline and its idle flush while the test's storage runs on a simulated clock; a schedule can therefore depend on how fast the machine is. And a schedule that did not end used to look like a slow run; it is now stopped and named.
The limits were then tested instead of added up: one server with the flags of the Kubernetes manifest, held to 1 GiB, under three loads (scripts/soak-memory.sh).
-
The server was killed at its memory limit although it kept every budget. The build under test was linked with glibc, whose allocator keeps freed memory in an arena for each thread: 1,481 MiB under a load that needed 446 MiB. The static binary stayed inside the limit and showed the opposite fault: the read figures published with release 2.0.0 could not be reproduced with the binary that release shipped. They had been measured with a glibc build. The static binary is linked with musl, whose allocator takes one lock for all threads, and read a tenth as fast: 21,376 strong reads a second on a local directory where 194,523 were published. The binary now carries its own allocator, so that neither speed nor memory depends on how it is linked. mimalloc was tried first and was killed at the limit; jemalloc with eight arenas, returning freed memory within a second, stays at 618 to 659 MiB and reads as fast as the glibc build did. Every figure in performance was measured again with the static binary, and that page says so.
-
The load generator misreported back-pressure. It gave up at the first
503while loading its keys and counted a503during a run as an error. It now waits and tries again while loading, and reports refusals apart from failures. Its values were one repeated letter, which compresses to almost nothing, so a load of large values wrote small tables;--random-valueswrites text that does not compress. -
Two tests of the HTTP boundary passed where they were written and failed on the build machines, whose processors run this suite about 3.5 times slower. Each held an answer of 24 MiB that nobody read and expected the server to keep it while the test did more work, against a server set to give up on such a caller after 0.4 or 1 second; on a slower processor the work took longer than that. So the commit of release 2.1.0 was never built by CI, and the website showed the documentation of 2.0.0 until this was fixed; the release's binary was built from that commit by the same
Dockerfileon the development machine, where the tests passed. The failure was reproduced by giving one test 28% of a processor. The tests that look at what is held now use a server that never gives up, giving up has a test of its own in which nothing else is going on, and a wait in that file allows a minute.scripts/test-slow.shruns every test alone on a fraction of a processor. -
On Backblaze B2 every commit sent one of its two uploads to a storage pod the server had never used, and each further upload of a slow object went to another. A new pod costs a call for its upload URL, a name lookup and a TLS connection. One database commits about ten times a second, and ten new pods a second went unnoticed. 64 databases committing at once asked for 160 a second: measured from the desktop these figures come from, which is on Wi-Fi, one such upload in fourteen then failed after waiting five seconds for its connection and the others took 0.8 s at the median, while uploads to pods already in use took 76 ms. The pods the server kept were only those within 2.5 times the fastest, so there were never as many as there were uploads under way, and the uploads started because another was slow went to new pods as well. That is the slow row of release 2.1.0 and of 2.0.0, which the notes of 2.1.0 left unexplained. Of ten new pods tried one at a time, four stored 4 KiB in under 100 ms and six took 160 ms to a second, on a connection already open as much as on a new one.
Since 2.1.1 the upload that must be sent takes the fastest pod known. A duplicate is the store's to decline (
put_spareinsrc/store/mod.rs): on B2 it is sent on a known pod that first uploads are not expected to need, or on a new pod while fewer than eight are on trial, and otherwise not at all; one that is not sent has stored nothing and is asked for again. Pods are kept in order of speed unless they are slower than a new pod usually is. A test holds the first upload while the store declines every spare and checks that nothing is acknowledged, that the spares are sent once the store has room, and that a first upload that fails is sent again; unit tests check the pool's rules. Eight faults put into this one at a time each fail a test. Performance has the measurements before and after. -
Two tests could be given the same port for their servers. The HTTP and cluster tests asked the system for a free port, closed it, and started a server process on it; the system may give the same port to the next caller. It did once, while the binary of 2.1.1 was being built: one server could not listen, and its test sent its requests to another test's server, which answered 401. Test servers now take ports below the range the system picks from, each given out once in a process, and a server that stops while it starts fails its test by saying so. The two suites then ran twelve times each without a failure.
-
The slowest commits in the Backblaze tables were stalls of the measuring desktop's own link. The desktop is on Wi-Fi, and a ping to its router had replies delayed by up to 2.4 s about once a minute. A build that logged every request showed all connections stalling together in those moments: four uploads to four pods and a name lookup in one, a claim check and an unrelated upload in another. Of twelve runs made with the ping alongside, the one with a stall in the ping is the one with a 99th percentile of 1.6 s. A figure published with 2.0.0 and 2.1.0 for what racing uploads gain (a 99th percentile of 2.2 s without, 0.45 s with) was measured before this was known and is withdrawn; performance gives what was measured since, with the releases run in turn.
The same link failed two tests of
tests/bucket.rs, once each: a purge of a thousand requests, and three reads of the read-after-write test in one moment, each with a request that could not be sent. Those tests unwrapped every request. A request that fails says nothing about what the bucket stores, so they now send it again as the engine does, and a read sent again still starts after the write it follows returned. The purge that was interrupted is purged again, and the deleted key must stay absent through both. -
A test of flushing and merging expected what a fast machine does.
flushes_merges_and_collectsunwrapped 1,300 commits to a small database, waited 200 ms, and expected four tables at most. A database refuses a write while more than four flushes' worth is waiting, and a merge takes as long as the machine makes it: of 40 runs on a processor held to 40% of one core, three failed on a refused write and one on a fifth table. The fifth table is not only a matter of time. With the test waiting for the flush instead, five tables were still at rest in two runs of 160, which the merge rule allows: runs are merged from the newest while they are together at least half the size of the next, and up to twelve may remain. The pipeline of the commit that carried release 2.1.1 failed in its test step. Its log was not read, so which test failed there is not known; this is the one that failed when the suite was run ten times on a slowed processor, andscripts/test-slow.sh, which runs each test once, had passed it. The test now sends a refused write again, waits for the flush instead of for a time, and expects the rule's own bound. It then passed 150 runs at 40%. -
Five runs of the Kubernetes test were read as a difference between two releases. Its read load measured 115,943, 119,493 and 115,589 session reads a second with 2.1.1 and 163,283 and 139,882 with 2.1.0, and the notes of release 2.1.1 said that the figure had gone the wrong way for a reason not established. Four more runs measured 118,284 and 159,921 with 2.1.0 and 144,577 and 130,334 with 2.1.1: the figure moves by a third from run to run with either release. The notes were corrected the same day. Looking for the reason found what the figure mostly measures: a read that reaches a pod not holding its database is relayed to the one that does, at two and a half times the cost, and more than half of the test's reads are relayed. The test now prints how many. Performance has the nine runs and what was ruled out.
-
About one purge in four failed when many databases collected at once, and the log did not say why. Counting storage failures in runs already made showed it: with 64 databases on Backblaze B2, 5% to 13% of purges failed in runs of ten seconds, with 2.1.0 and 2.1.1 alike. The debug log said only "error sending request". A build that logged the cause showed connections reset by the other side, nearly all of them in the two seconds in which every database collected: five seconds after the load stopped, when all of them flush, and again when the server was stopped. A purge removed each version with a request of its own, 32 at a time for each database, so 64 databases opened about a thousand connections at once.
Two smaller changes were measured first and not kept. Sending a failed removal again ended the failures and left the connections: in a run of 100 seconds, where every database also collects once under load, 2 of 633 purges failed against 154 of 647, and the commits beside them were slower in that pair of runs (p99 545 ms against 298 ms). Allowing 64 such requests at a time over the whole server ended the failures, held fewer connections and made the purges slow: 127 of 633 took over ten seconds, and a database cannot be released while it collects.
Since 2.1.2 one request removes up to a thousand versions, which is a second wire form of the one operation, defined by the S3 API and taken by Backblaze; a store that refuses it gets a request for each version as before. A request of a purge that is not answered is sent again twice, a storage request that fails logs its cause at debug level, and an answer of
501from a store is a refusal, not a reason to wait and repeat. Measured with the two releases in turn: with 64 databases written for 100 seconds, 156 of 629 purges failed with 2.1.1 and none of 645 and of 643 with 2.1.2; with 64 databases left alone after ten seconds of writes and the server then stopped, 26 of 158 and 75 of 159 failed with 2.1.1, which held 1,136 and 1,486 open files, and none of 159 and of 156 with 2.1.2, which held 248 and 258, fewer than under the load. Performance has the tables. -
A test of the disk cache waited for a count that can be reached with a table missing.
an_empty_disk_cache_is_filled_two_tables_at_a_timeread twelve tables until the cache counted the bytes of twelve, then expected a pass of reads to miss none. It failed once in four runs of the suite made before this release, and then 7 times in 360 runs alone, on a slowed processor and on a fast one. A table that is read while its first fetch is finishing can be fetched a second time, and the cache counts its bytes again although it holds one copy. The count is put right when the cache is next trimmed; until then it can be trimmed sooner than it has to be. The test now waits for the pass without a miss: 600 runs of 600 pass. Release 2.1.2 has the count as it was. After it, a table that the cache already holds is not written or counted again, and the test puts one there twice and expects the bytes of twelve: it fails without the change, and 600 runs of 600 pass with it. -
A store that keeps no versions was refused. Until it was looked for, durable-db had been run on Backblaze B2 and on nothing else that speaks the S3 API. Run on three S3 servers in containers, the bucket tests passed on a community build of MinIO and on RustFS, and on Garage every purge failed: Garage keeps no versions and answers
501to the request that lists them, and a purge began with that request. A server did not start there at all. Its storage check ends by purging what it wrote, and it stopped with "the storage check failed": the right answer to a store that cannot be cleaned up, and the wrong one to a store where a key that is removed is gone.Since 2.1.3 a store that answers
501to a listing of versions is taken to keep none. A purge there lists the keys and removes them, with one request for up to a thousand or with one each, and the store is not asked for its versions again; the server says so once in its log. A store that kept versions and could not list them would keep what such a purge hides; none is known. With that, a server starts on Garage, the bucket tests pass there, and a ledger of 75,156 transfers verified through three servers of which two were killed and one stopped, with 347 purges and none failed.Three smaller things were found the same way. On RustFS 14 of 157 and 11 of 158 purges failed in two runs of that ledger: RustFS answered that single versions named in a request had not been removed (
ServiceUnavailable), and a purge failed at once on such an answer. The request is now sent again, like one that is not answered, and no purge has failed in four runs since. One bucket test expected 521 keys to be purged where a bucket that keeps no versions has one left, and failed on such a bucket. And the test of the storage contract unwrapped every request: it failed once on Backblaze when a request could not be sent over the desktop's link, and now sends one again as the engine does.scripts/test-stores.shstarts the three servers and repeats all of this. 26 faults put into the purge one at a time, ten of them into the purge by key, each fail a storage test. -
Two requests were sent in a form that not every store takes. After finding 34, the providers that have not been run were asked what they can be asked without an account. Amazon S3 and Google Cloud Storage both list public buckets for anyone, and both say in their documentation what they require. Cloudflare R2 answers nothing without an account.
- Google answers a listing of versions in a shape of its own: a
ListBucketResultwhose versions carry aGenerationand noVersionId. A purge takes that for an answer from something other than the bucket. A server's storage check ends with a purge, so a server would not have started there. Asked with the headerx-goog-interop-list-objects-format: enabled, Google answers in Amazon's shape, and a second page asked for with the markers of the first was answered. A listing of versions now carries that header, signed, as Google requires of everyx-googheader. - The request that removes many versions carried a SHA-256 checksum of its body and no other. Google refuses that and says what it wants: "Missing required header for this request: Content-MD5 OR x-amz-checksum-crc32." Amazon's documentation calls
Content-MD5required for this request. A refusal would have cost speed and nothing else, since a bucket that refuses the request gets one request for each version. The request now carriesContent-MD5, which Backblaze B2, MinIO, RustFS and Garage take as they took the other. - Amazon answers a listing of versions of a bucket that keeps none as was assumed: each object once, its version named
null. Google pages a listing of keys as Amazon does, by token and by the key to start after.
None of this is a run. durable-db has stored nothing on Amazon S3 or on Google Cloud Storage, and the requests above were sent without a signature, so it is not known that either takes a signed one. What R2 answers to a listing of versions has been read and not seen: its documentation lists the request as not implemented, and others report a
501, which is the answer of finding 34.With the change, the bucket tests pass on Backblaze B2 with native uploads and with PutObject only, and on the five buckets of
scripts/test-stores.sh, none of which refused the request that removes many versions; the script now names a store that does. - Google answers a listing of versions in a shape of its own: a
-
A server with more than twenty databases open stopped its housekeeping. Once a second a server follows its peers, hands databases to the members that now own them, releases the ones nobody uses, and keeps unflushed writes and remembered keys within their budgets. That is one task. It began by sorting the open databases by how long each had been idle, and read that from a clock at every comparison, so the order changed while the sort ran. The standard library may refuse such an order with a panic, and does so only above twenty elements. The panic ended the task and nothing started it again. The server went on answering: with the peers it knew at that moment, handing nothing over, releasing nothing, and holding to neither budget, until it was restarted. Every release from 2.0.0 to 2.1.3 has this.
It was found in the log of a server to which 256 databases had written for five minutes on Backblaze B2, a run made to measure something else, in which no request failed. With the released 2.1.3 binary on a local directory, 64 databases in use and
--idle-seconds 5, there was a panic within 90 seconds, and twenty seconds after the load all 64 databases were still open. In a test, 20 databases or fewer did not panic in five runs of 2,000 sorts, in use or idle; 21 or more in use did in every run, and idle in two runs of twenty.No check had looked. No test held more than twenty databases open on one server for longer than a moment (the Kubernetes test spreads twelve over its pods), the benchmarks with 64 and 256 databases ran for ten seconds, the memory soak with 256 for a minute, and no script read a server's log for a panic. Those runs were made on servers that may have stopped their housekeeping partway. What the benchmarks measured within their first minute (commits, purges, open files) does not depend on it; the memory soak does, and was run again.
Since 2.1.4 the idle time of each database is read once before they are sorted, and a round of housekeeping that panics is one round lost: it is reported as an error and the next round runs.
tests/engine.rstends 96 databases in use 2,000 times, which fails within 10 ms with the old sort, and runs a round that panics, which fails without the guard. With the old sort put back under the guard, 16 rounds of the same 90 seconds panicked and every database was released when it fell idle. A database's own tasks were already kept in this way: a panic there closes that database, and it is opened again from the bucket. The server's own task was not. The four scripts that run servers now fail when a server's log holds a panic. -
Backblaze refused every upload for five and a half minutes, eleven minutes into a run. The five-minute run of finding 36 was made again for twenty minutes with 2.1.4, to see where memory stops: 256 databases, one client each, one server. For eleven and a half minutes it committed 1,333 times a second on average, which is about 1,750 uploads and 1,330 HEADs a second. Then Backblaze answered
503 Service Unavailableto every upload, and GETs, HEADs, listings and deletions failed with them. The desktop's link was working: of 4,710 pings to the router five took longer than half a second.Backblaze's documentation gives a new account 500 requests a second for uploads and downloads, and says that an account beyond its limit is answered
429by its own API and503by its S3 API. The run was at about six times that figure, as the five-minute runs were for as long as they lasted. That makes the limit the likely cause, eleven minutes late, and it is not established. What the uploads were answered by Backblaze's own API was503, where the documentation says429, and503is also what a fault at Backblaze would answer. durable-db logs the status of such an answer and not its code or itsRetry-After. The run was not made again to find out: an account that goes on doing this is one Backblaze may act on, and a limit on an account is a limit on every bucket in it.What durable-db did is what architecture says of storage that is unreachable. No commit was acknowledged from the moment the uploads failed. Each of the 256 clients had one commit answered with an error. Every database was closed about half a minute later, when its flush failed. When uploads were accepted again, every database was opened again within a minute and committed for the rest of the run.
Two things in it are not good. In the first half minute some 28,000 uploads failed, about 800 a second: an upload that fails is sent again at once to another storage pod, which is what Backblaze asks for when one pod is busy and the wrong thing to do to a service that is refusing an account. And the server used 932 MiB at the moment all 256 databases were opened again together, against 683 MiB before, under a limit of 4 GiB.
Nothing was changed for this in 2.1.4. Reading the code and
Retry-Afterof such an answer, holding back when an account is refused, and keeping a server's own requests under a rate it is given are the next work. Until then the figures in performance for many databases on Backblaze are of a rate that an account with the default limit cannot expect to keep. -
A server went on sending a store what it refused. The 28,000 uploads of finding 37 were sent by design. An upload that fails is sent again at once, up to four times on Backblaze, and all of that again after 10 ms, after 20 ms and so on up to a second, for the thirty seconds a database gives its storage. A read or a deletion that fails is sent seven times. Nothing in this looked at whether the store was taking anything at all.
Since 2.1.5 a server counts refusals, for each kind of request apart: reads, changes, and on Backblaze B2 the uploads to its storage pods and the calls that name a pod. A refusal is an answer for which a request is sent again:
429,408, a5xxother than501, a connection that failed, a request that stalled. After eight in a row, with no request of that kind taken between them, requests of that kind fail in the server without being sent. After one second, or after as long as the store asked for inRetry-Afterup to a minute, one request is sent, and the others go on failing until it is answered. If it is taken, all are sent again. If it is refused, the wait doubles, to four seconds at most. The kinds are counted apart because a store limits them apart, and a read that is taken would otherwise hide uploads that are all refused. The waits are short because what spares the store is one request in place of hundreds, and a longer wait is that much longer without the store once it takes requests again.A request that fails without being sent has stored nothing, and every caller already had to allow for a request that failed and stored nothing: the protocol and the model are unchanged. The server logs the eighth refusal, and each request it tries after that and has refused, with the store's status, its error code and the wait it asked for; and it logs when the store takes requests again.
It is tested in three ways. The counting runs against a clock the tests set: seven refusals and then a request that is taken, a hundred times over, hold nothing back; one request at a time is tried; a request on trial that is given up lets another be tried; requests that were under way when the store began to refuse change nothing by being refused late; a store is left alone for as long as it asks. Two stand-ins are refused to: the S3 stand-in as in the table above, and a stand-in for Backblaze's API that refuses every upload, of which eight are sent, and then of sixty more none is sent, none takes an upload URL from those the server holds, and none calls for a new one. 27 faults put into it one at a time each fail a test. And
scripts/test-refusals.shputs a proxy that refuses in front of a real S3 server, with the figures in the table above.On Backblaze B2 itself, at a rate under the limit of its documentation, nothing was held back: in two minutes of 87 commits a second over 8 databases, about 255 requests a second, 9 of 21,257 uploads were refused, each was followed by one that was taken, and the server logged no warning. The Kubernetes run of the table above passed with 2.1.5 as well.
Two things it is not. It is not a rate: a store that takes some of what it is sent is sent all of it, so an account a little over its limit is sent as much as before. And it has not been seen on Backblaze. The refusal of finding 37 was not made again, for the reason given there, so what Backblaze says when it refuses has still not been read. The next time it happens it is in the server's log.
-
A store that was slow to list was taken to refuse reads. One server of 2.1.5 with the flags of the Kubernetes manifest, held to 1 GiB, was run on a community build of MinIO in a container on the same desktop, held to 4 GiB and four CPUs: 256 databases, each written by one client for twenty minutes, to see where memory stops when the store is a bucket. Memory was not the finding: 532 and 556 MiB at most in two runs, and level from the third minute. Nor were commits: 2,216 and 2,070 a second, and none failed.
From the fourteenth minute, with two million objects stored since the start, MinIO took longer than twenty seconds over listings of what a database had to collect. A request that has no answer after twenty seconds is given up, so those purges failed, about one in two from then on, and what they would have removed stayed in the bucket until a later collection. That much is the store's.
What followed was durable-db's. 2.1.5 counted a request that was given up as a refusal, and counted listings with every other read. While the databases were written, the read that each commit waits for was answered two thousand times a second, and eight listings were given up in a row with none of those between them once, for 19 ms. When the writing stopped, listings were most of what was read. In the next 80 seconds the server took the store to refuse reads ten times, and each time sent it none, the reads it would have answered at once among them. Twice the one request that tried the store was slow itself, and nothing was read for 8 and for 23 seconds, until that request was answered or given up. 120 flushes and 5 merges failed for a read that was not sent, and of the 256 deletions that followed, 16 were answered
503. In the first of the two runs the log was not kept; it had 24 such warnings.Since 2.1.6:
- A request that is not answered in time is not a refusal. It is sent again as before, and counts neither as refused nor as taken. The count is there for a store that answers at once that it will not take a request, which is what can be sent hundreds more a second in place of those it refused (finding 38). A request that waits twenty seconds for nothing cannot: whatever sent it sends the next no sooner than that.
- Listings are counted apart from other reads, as changes already were. A listing costs a store what no other read does, and Amazon S3 and Backblaze B2 both price it apart.
- A request that tries a store which has been refusing is waited for no longer than a refusal is waited out, which is one second to four, or what the store asked for. Then another is tried.
The counting is tested against a clock the tests set: requests that are not answered, however many, hold nothing back, and one between seven refusals and an eighth does not end the run; a request on trial that has had the wait lets another be tried, and ends without taking that one's place. A stand-in answers no listing at all and stops in the middle of a table's bytes, sixteen of each at once: nothing is counted, and the next listing and every read are sent. The S3 stand-in refuses listings as in the table above. A stand-in for Backblaze's API refuses the call that names a storage pod: eight are sent and then none, and one a second later when it takes them again. 39 faults put into all of it one at a time each fail a test; twelve of them are new, and one of those passed every test until the test of a request on trial was made to wait out a doubled wait.
The same run with the change, by
scripts/soak-bucket.sh: 2,000 commits a second and none failed; 557 MiB at most, and 425 to 532 MiB from the third minute; one purge in ten failed, 1,636 of 16,144, as MinIO took as long over its listings as before; the server held nothing back and failed no request for one it did not send; and none of the 256 deletions failed. They took twelve minutes, and one of them seven, and a round of the server's housekeeping ran for over two minutes: the next finding.2.1.5 on Backblaze B2 has not been seen to do this. It would take eight requests of one kind that go unanswered, or are refused, with none answered between them, and a store that then is slow rather than refusing.
-
A slow store held up a deletion, a release and a server's housekeeping. In the run of finding 39 with that change, on a MinIO that took more than twenty seconds over a listing, the 256 deletions took twelve minutes, one of them seven, and one round of the server's housekeeping ran for over two minutes, which the log said every thirty seconds.
A collection made every one of its purges while it held its database's maintenance: the frames a flush covered, the manifests before the last, and one purge for each table a merge had replaced. Each is a listing, and a listing that is not answered is sent three times before the purge fails. A deletion of that database, or its release, waited for all of them. And a round of housekeeping released the databases that had been idle for five minutes, 255 of them at once, and waited until each was released: meanwhile the server followed no change of its peers, handed no database over and kept to neither memory budget.
Since 2.1.6:
- A collection gives way to a release or a deletion at once, in the middle of a purge if it is in one. A release still collects what it leaves, and a deletion removes everything.
- A collection ends at the first purge the store does not answer, and does not ask it for the rest. What is left is collected after the next flush, or by the next owner, which removes whatever an earlier one left.
- A round of housekeeping does not wait for a release. Each is made in a task of its own; no more are begun for a change of membership while sixteen are under way; and a server that stops waits for those that are.
Since 2.1.11 the sweep of what an earlier owner left gives way as well. It is one listing of the whole database, and a release or a deletion that began while a new owner swept waited for it to end.
None of this changes what is deleted or when it may be: a purge that is not made deletes nothing, and one the sweep sent that arrives late deletes only what every later owner's sweep would. Six tests hold or fail single requests for it: a deletion and a release each end while a purge of a collection is held, and each while a new owner's sweep is; a collection whose first purge fails makes no other and leaves the table a merge replaced to a later one; and a round of housekeeping ends while a release waits for the store, which a server that stops then waits for. Nine faults put into it one at a time each fail one of them, and the sweep that does not give way fails both of its tests.
The run again, by
scripts/soak-bucket.sh: 1,994 commits a second and none failed, 558 MiB at most, nothing held back. The 256 deletions took five minutes and none failed. The slowest took two: a deletion lists everything its database has, and that is the store's time. What that one waited for was not looked at. -
A database that reached its quota stayed there. A database's size counts every table it has stored, and a value that was written over or deleted is stored until a merge reaches the table that holds it. Tables are merged by size, the newest with the next when they are half as large, and nothing merged them for the quota's sake. Two runs of 2.1.6 on a local directory, each with a quota of 64 MiB:
- 2,800 keys of 16 KiB, which is 45 MiB, were written and then written over at random (
durable-db bench --workload fill --database q --max-bytes 67108864 --keys 2800 --value-bytes 16384 --random-values --clients 8, then--workload write --seconds 40in place of the fill). After 2,966 more writes the database held 64 MiB, and every write from then on was answered507: 1.3 million of them in what was left of the forty seconds. Nothing would have ended that. A database that takes no writes makes no tables, and so no merge. - A database was filled to its quota and every key in it deleted. It then held 65 MiB, the deletions being counted as well, and a write of 2 MiB was refused.
Delete data or raise the quota, the documentation of that error said.
Now a write that the quota has no room for asks for everything to be merged, when the database has more than one run of tables or has writes that are in no table yet, and is answered
503while that is done, as a write is that waits for a flush. It is taken when the merge has made room, and answered507when it has not, or when there was nothing to merge. With the change the first run made 493 writes a second for the forty seconds and none failed; the clients were told to wait 83,833 times, by a benchmark that asks again at once. In the second the write of 2 MiB was told to wait, since what had been deleted was not merged away yet, and was taken 2.6 s later; the database then held 2 MiB. Those seconds are the wait after the merge that the fill had ended with, which had made no room.A merge of everything rewrites the database, and a database that is full of what can still be read would ask for one with every write. So after such a merge that removed less than an eighth of what it merged, the next waits four times as long as that one took, and a second at least; a write with no room is answered
507meanwhile, or503if something has been deleted since that merge, which the next will take in. As first written, a deletion ended the wait, since it is how room is made. Then a client at a full quota that deleted one key and wrote one had everything merged for that write, and for the next: two requests for a rewrite of the database, as often as it could be rewritten. Only time ends the wait now. A merge for the quota also flushes first: one that began with a write still in no table left the value it had written over in place, and was then waited after.The protocol is unchanged: this is the merge a database then made when it had more than twelve runs, which since 2.1.8 merges only the newest of them (finding 44). Four tests in
tests/engine.rsand two intests/interleavings.rs; 15 faults put into it one at a time each fail one. Found by filling a database and writing over it, when the question was what a larger quota would cost. - 2,800 keys of 16 KiB, which is 45 MiB, were written and then written over at random (
-
A merge that took longer than a database may be idle would never have been finished. A server releases a database that has not been used for five minutes (
--idle-seconds), and a merge under way stops at a release. Use meant requests. So a database whose clients went quiet while it was merging was released in the middle, what the merge had uploaded was discarded, and the next owner began the merge again from its start when the database was next written to. A merge of everything a database holds takes as long as reading it and writing it again: at 50 MiB a second, five minutes is 15 GiB. Below that it was a merge made twice now and then. Above it, a database written in bursts would never finish one, and its tables would grow in number, with what is counted against its quota. This was read in the code while larger databases were measured; no run has shown it, since none has had a merge that long. A merge is now use, when it begins and with each table it stores. One test intests/interleavings.rsholds back each table of a merge, runs the server's housekeeping meanwhile, and expects the database to stay; 2 faults fail it. -
A server that read more than its disk cache held fetched tables over and over, in every release up to 2.1.7, which reported it and did not fix it. The disk cache kept whole tables and, over its budget, put out those that were written longest ago. A read whose table was not there read the block it needed from the store and had the whole table fetched behind it, two tables at a time. That table took the place of others, which the next reads missed in their turn. When the databases a server read were larger than its cache, this did not end.
scripts/soak-size.shwith a database of 4 GiB and the manifest's cache of 1 GiB, on a local directory: 14,228 reads a second of values of 4 KiB, which is 56 MiB a second to the clients, and 73,388 MiB read from the store in that minute, which is 1.2 GiB a second and twenty-two times as much. By the server's count of its requests, three for every two reads, some 0.7 GiB a second of that were the blocks the reads asked for, 32 KiB for a value of 4 KiB, which is the cost of a read that finds its table in neither cache. The rest were whole tables, some sixteen a second, and those did not depend on how many reads there were: one read that missed was enough to fetch a table. A local directory gave that at once. A bucket gives it at the speed of the link and bills it as download, and meanwhile most reads wait for the bucket. A merge of tables that were not in the cache read them a block at a time, a thousand requests for a table of 32 MiB, and had each fetched as well: while that database was filled, 9,846 MiB were read back of the 28,230 MiB that were sent. Nothing wrong was answered, and memory was not affected. It was found by the count of bytes read from storage that the script of 2.1.7 prints beside each of its loads; no earlier measurement had a database larger than the cache.Since 2.1.8 the cache knows what it holds, and in what order that was used, without asking its directory. A table this server wrote is taken as before, and the least recently used make way for it. A table that reads miss is read from the store a block at a time until they have had a sixteenth of it, so that what is fetched is never more than sixteen times what was read, where one read of 4 KiB had fetched 32 MiB. It is then fetched into room that is free, or that tables no read has asked for in five minutes leave, and never in the place of a table in use. A merge reads each of its tables once and has none fetched, and what it replaced leaves the cache when it leaves the manifest. A scan, which a merge is, asks the store for one block, then two, then four, up to 64 blocks or 1 MiB in a request, and for nothing past its own end.
Two things were wrong in that change as it was first written. Both were found by reading it again before it was measured, and no test had shown either. To see whether a table had room, every read that missed walked the tables that had gone unread, with the cache's lock held: a server with thousands of small tables unread, and not enough room among them for a large one, would have walked them all for each such read. A read that misses now looks at one table, and tables that have gone unread are put out as they are found. And what a scan had read ahead was in memory, 2 MiB for each run of tables it read, with nothing to bound how many scans did so at once: some hundreds of scans of large databases would have passed a server's memory limit. Now sixteen scans of requests and sixteen runs of tables in merges read ahead at a time, 1 MiB each, the others read a block at a time, and a request's scan reads ahead only in a table that is not on the disk. The cache also holds no more than 262,144 tables, so that what it remembers of them is 40 MiB at most.
Four more were found by a second reading, by a reader that had not written the change, before it was released. None of them answered anything wrong. A damaged copy in the disk cache is discarded by the reader that meets the damage, which then reads the store's. A second reader that had the copy's bytes at the same time found nothing left to discard, and was answered that the table is damaged though the store's was whole. That was so for two reads of a block in every release; a scan that reads ahead holds up to a megabyte of the copy, and for longer. A reader on a server with a disk cache now reads the store's once before it says so, whoever discarded the copy. A scan kept what it had read ahead, and its turn, after it had come to the last block of it. A merge keeps the scans of the runs it has read through until it has published, so a merge of thirteen runs left three turns to the other. A scan now gives both up when the block it comes to next is not among those it read. The cache removed the files of the tables it put out with its lock held, and every read of a table waits for that lock: a table of 32 MiB written into a cache of small tables could remove thousands. They are now removed when the lock has been let go. And a table that was written, and that would not fit beside the room promised to tables being fetched, put out every table before it found that out. It now puts out none; that needed a cache of under 200 MiB.
Three more were found by measuring it, before it was released. None of them answered anything wrong; each had a server read from its store what it had held on its disk. A table that a merge stores is put into the cache, and the least recently used made way for it. In a merge those are the tables it has not come to yet: every table it has read was used after them. A merge of everything, in a cache as large as the database, so put out its own tables ahead of itself and read them from the store, and since a merge reads and stores one table after another, each such read took its turn with an upload. On Backblaze B2 a write at the quota of a database of 1 GiB waited 752, 906 and 1,020 seconds in three runs of
scripts/soak-size.sh, where 2.1.7 had waited 525; on a local directory, 838 MiB were read back while that merge stored 1,053 MiB. A table a merge stores now never takes the room of a table that merge has yet to read through, and is not kept when there is no other room: that the merge will read those tables is certain, and that its own table will be read is not. With only that rule the same run still read back 549 MiB, where the database held 210 MiB more than the cache: a merge whose tables were all in the cache left half of its result there. The tables it stored had made way for one another, and for what else was in use, while the tables it had read through stayed until it was published and then left. A table a merge stores now takes room that is free, then that of a table no read has asked for in five minutes, then that of the tables its merge has read through, and only then that of the least recently used. And a table that a read had missed was fetched in the background while a merge replaced it; it arrived after the merge was published and was kept, though no manifest listed it, and counted as in use for five minutes, like one that had just been read. After a merge of everything under 64 clients' reads, in a cache of the database's size, one such table kept the last table of the result out, and one read in thirty went to the store. The cache now remembers which tables have left their manifests, up to 65,536 of them, and neither fetches nor keeps one. With the three, the merge for the quota in that run read back 354 MiB, where the database held 316 MiB more than the cache, and after a merge of everything under reads the store was asked for nothing. What it costs: while a merge runs in a cache that has neither free room nor a table that has gone unread, requests read the tables that merge has read through from the store, until it is published.Three more were found in those rules by a third reading, again by a reader that had not written them, before they were released. None of them answered anything wrong. The tables a merge has stored are read by nothing until it is published, and a merge of a few gigabytes into a slow store runs for longer than the five minutes after which a table counts as unread. Its first tables then made way before any other, for its later ones and for tables fetched for requests. The flush that a merge gives way to between two of its tables stored its table by the order of use alone, and could put out a table the merge was coming to. A table that is stored while a merge runs, by the merge or by a flush it gives way to, now never takes the room of a table that merge has yet to read or has stored, however long the merge runs. And what the cache remembers of the tables that left their manifests was forgotten all at once when there were 65,536 of them, with those that had only just left, and one manifest that dropped more than that was remembered whole. The first to leave is now the first forgotten, and there are never more.
A fourth reading, of those three changes, found nothing that answers wrong, loses a table or breaks the cache's counts, and three things the rules do not cover, which stay as they are in this release. Against a table fetched for a request and against a table another database stores, a merge's tables are in use as any table is: used when the merge last stored a table, and unread five minutes after. A merge that stores nothing for that long, as when a flush it gave way to waits for the store, can so have them put out, and reads from the store those it had yet to read. The cache removes a file after it has let go of its lock; a table that is put back in between, by a fetch that arrives just then, is counted as held with no file, until the next read of it finds that out and reads the store's. And a read that is answered from the cache in memory is not use of the table on disk: a table whose blocks in use are all in memory counts as unread on disk after five minutes.
The protocol and the storage format are unchanged. Ten tests of the cache by itself in
src/io.rsand thirteen intests/interleavings.rs, and the test of a damaged cache intests/engine.rsnow expects the cache to hold the manifest's tables and no others; 92 faults put into the change one at a time each fail a test. What remains, beside what the fourth reading left, is what a read beyond both caches costs: a request to the store for each run of tables it looks in. And in use means read from the disk in the last five minutes, not read the most. -
A database that was written while it merged was left with a run for every flush, and a read looked in each. Two runs of the size soak at 16 GiB on a local directory, of the build that was to be 2.1.8 and with nothing changed between them, read 27,575 and 29,039 keys a second in one and 6,119 and 7,330 in the other. The second also read 60 KiB from its store for each request where a block is 32 KiB. Nothing in the disk cache accounted for it: a merge of everything during the reads, and one begun on an empty cache before them, each read at 22,000 a second and more.
What differed was the moment of the kill. The soak kills the server that filled the database, and in the slow run the kill found it in a merge of the whole database. The table of a flush is a run, and a merge gave way to flushes between two of its tables and to nothing else: every flush made while a merge ran stayed a run until the merge ended, one for each 8 MiB written, for the two minutes a merge of 16 GiB takes on a local directory and for far longer on a bucket. Copies of the database were kept from such kills and read with the same build and flags. With 7 runs it read 22,664 and 21,674 keys a second, with 14 runs 15,619 and 16,016, with 19 runs 10,271 and 12,559, and with 27 runs, seventeen of them single tables of 8 MiB, 5,281 and 6,521. One of the copies, written over by 64 clients for 400 seconds more, had over 110 runs before its merge of everything ended. Those copies were made by writing over a database until a kill found it so, and one command does not make them:
SOAK_RUNSwas added to the soak so that the same can be asked of a release from 2.1.8 (performance).Three things were wrong with the 27 runs, beside there being 27. A read looked in each, which is processor time. The memory cache counted a table's index as it counts a block, and with a block of every run passing through it for each read it held two thirds of the indexes at a time, 20 to 22 MiB of 30: an index that was put out is read again with the end of its table, 256 KiB where a block is 32 KiB, and a third of what the server read from its store was that. And the server that opened the database rewrote all of it. A database with more than twelve runs merged everything, so 16 GiB were written again for seventeen tables of 8 MiB, beginning half a minute after it was opened, since a merge waited for a write or for the second sweep, and with every one of the runs still read until it ended.
Since 2.1.8:
- A merge gives way to merges as well as to flushes. Between two of its tables it flushes what has fallen due, and then, when the database has more than twelve runs, merges the tables flushed since it began among themselves, by the rule of sizes, each such merge published by itself. Those merges take together no more than the merge that gave way has itself stored, and give way to flushes only; what falls due during one is flushed when it is published. A merge that gave way stops, when the database is released, as soon as the one it gave way to has.
- A database with more than twelve runs merges the newest that are too many into one, and nothing else for their sake.
- A merge that is due when a database is opened begins then.
- A table's index stays in the memory cache for a minute after a read last asked for it, whatever blocks want its room, as long as the indexes in memory are together within half the cache and sixteen of its size fit in one of the cache's parts. Past that they go as blocks do, and the cache keeps its bound.
The copy with 27 runs, read by release 2.1.8 with the same flags, beside another soak of 256 databases on MinIO: 14,351 and 14,595 keys a second, and 20,971 scans, where the build before had read 5,281 and 6,521 and scanned 4,577. The server that opened it had merged the seventeen newest runs into one within two seconds. A database written over in the same way no longer gains runs so:
scripts/soak-size.shwithSOAK_GIB=16 SOAK_RUNS=16wrote over the database of 16 GiB with 64 clients for 571 s before it had 16 runs, and the server that opened it then read 12,004 keys a second in the first minute, while it merged, and 18,255 in the second (performance). A build of these changes, written over for 400 s from one of the kept copies as the build before had been, had 18 runs at most where that build had passed 110.A server was killed at its memory limit by what it wrote to its own disk cache, which the first build with these changes showed. It opened the copy with 27 runs, began the merge at once, and was killed by the kernel within three seconds, three times of three: 573 MiB that it had written to the cache directory were not on the disk yet, which with the 400 MiB of its own memory was the limit of 1 GiB. Bytes that are written and not yet on a disk are memory the kernel cannot give up, and they are counted against the group of processes that wrote them. The kernel holds such a group to its disk's speed only when the group has the controller for it,
io, beside the one for memory. The scopes these runs are held in have the one for memory alone, as a container may. The disk cache wrote its tables and did not wait for the disk, in every release that had one. No run before had been killed so, and none had stored tables and fetched them at the speed of a local directory in its first seconds. The cache now asks the disk for the tables it has written when they are more than 32 MiB or more than 64 tables, once at a time, and what wrote the last of them waits, as does whatever writes another meanwhile; a table that a request put there, which a client waits for, has the disk asked only at twice as much. Three servers of 2.1.8 that opened the copy with 27 runs and were read from their first moment were not killed, and answered 11,576 to 12,905 reads a second in their first 20 s.Two of these changes cost more as they were first written, which the size runs of the release that was to be showed, and the release was built again.
- The cache synced every table.
scripts/soak-size.shat 4 GiB on a local directory, where the store and the cache share a disk: the merge of everything at the quota took 47 s, where the same build without the sync took 31.5 s. Three quarters of the tables that merge stores are not kept in a cache of 1 GiB, and were synced before that was known. A table that is not kept is now not synced, and those that are, together; the same merge then took 34.8 s. - A merge gave way to merges whatever the number of runs. What is merged behind a merge is merged again with what that merge makes, so each such byte is sent to the store once more: the fill of 4 GiB on a local directory sent 7.2 times what was written, where the build before had sent 7.0. A merge now gives way to merges only while the database has more than twelve runs, and the fill sent 7.0 times, and 6.9 times with the release.
The protocol and the storage format are unchanged; a database's description gains its number of runs. Nine tests in
tests/interleavings.rsand four insrc/io.rsare new, and the test of the merge rule covers the limits; 49 faults put into these changes one at a time each fail a test, and the 92 of the disk cache's earlier changes still do. A test of finding 41, which wrote a key just after it asked for a flush, failed one build in two on the build machines: when the flush took the key in, a merge left out what the key wrote over, and the write the test expected to wait had room. It waits for the flush now. The suite is now also run with eight test threads on 2.3 processors, the build machines' shape, where that test had failed once in twelve runs; none failed in twenty runs after. Three readings by a reader that had not written the changes, before they were released. The first found that merges nested without limit: under writes that do not stop, a merge had given way to merges that gave way to others, and the first of them, which holds one of a server's two turns to merge, need never have ended. They are one deep now, and within what the first has stored. It also found that a merge that waited kept what it had read ahead, with turns of which a server has sixteen, and that indexes that were held could keep one part of the memory cache above its share on a machine of many processors, where a part was small. The second found that what fell due during a merge another had given way to waited for a table of each, and that one test would have passed without the rule it was written for. The third found that the bound on what had not been synced held only while one writer synced: a batch stopped counting when it was taken, and others filled the list again behind it. It also found that a request could wait for the disk to take what merges had written, that the file of a table that was put out stayed open, and was written to the disk, until the next sync, and that a limit of no runs would have panicked. All four are changed.What remains. A database that is written faster than its merges can be made still gains runs for as long as it is, and no write is told to wait for them: on Backblaze, over a link that carried 1.1 MiB a second, a database of 1 GiB had 32 runs when its fill ended, and was read at two and three keys a second (performance). A merge whose read of a table fails for more than a second or so, as over a link that resets its connections, fails, and is begun again from its start; on that link four did. Release 2.1.9 changes both (finding 45). A read of a key still looks in every run that might hold it, one after another, since a table says nothing of the keys it lacks; on a bucket, with nothing in the disk cache, that is a request for each. A merge that another gave way to tells the disk cache nothing of the tables the waiting merge has yet to read, and in a full cache its tables may take their room. The merge that waited reads again what it had read ahead, 1 MiB for each of its runs. And a failure in a merge that another gave way to ends that one too, as a failed flush does, with what it had stored.
-
No write waited for runs, and a merge was discarded for a store that failed for a second. Both were stated as limits of 2.1.8 (finding 44): over a link to Backblaze that carried 1.1 MiB a second, the fill of a database of 1 GiB left 32 runs, and every read of a key the disk cache did not hold asked the bucket for a block of each, one after another, two and three reads a second. Four merges of that fill failed on a connection reset: a merge's read of a table was tried seven times in some 1.3 s, as a request's is, and a merge that fails is begun again from its start when the database is next written to.
Since 2.1.9:
- While a merge is under way, a write is answered
503if the database would have more than twice twelve runs once that merge is published, the runs it takes counting as one. At each table it stores, such a merge merges what was flushed behind it, as far as what it has stored allows, where it had done so only when a flush fell due; and with writes refused, none falls due. - A merge's read of a table is asked again for ten seconds, and given up, a call under way among them, once a release or a deletion has begun or the database has closed. A request's read gives up as before, after seven tries. A merge loads the index of a table without the lock that requests for the same table wait on.
- What a merge gives way to, a flush or a merge behind it, may fail for a store that fails for a while, as a claim check that is not answered; it is asked for again later, and the merge goes on. Not past a store that refuses it for good.
Six readings by a reviewer that had not written the change, before it was released. The first three each found that the refusal could last far longer than meant, or that the patience did not reach where it was said to, and the design was changed each time; the last three found nothing that answered wrong.
- The first form refused writes whenever a database had more than 24 runs. A database waiting for one of the server's two turns to merge refused them for as long as other databases held both, though refusing could not bring its runs down; one whose merge failed every time refused them for good, and a wake that the refusal sent began the merge again for every refused write; a merge that passed the bound with nothing due to be flushed merged nothing behind it until it ended; a request for a table waited behind a merge's patient load of its index, under the lock that dedupes loads; and a release waited out a read of thirty seconds. The first reading by this project also found that, without the wake, a database whose merge had failed twice would never have been woken to merge again: its writes were refused, and only a write that is taken wakes the merges.
- The second form refused writes only while the database merged. It still counted the runs the merge under way was about to replace, so a merge that began with many, after a kill, after failures or after a long wait for its turn, refused writes for its whole length; merging behind could stall on the rule of sizes; and the documentation said that a release ends within the grace of the Kubernetes manifest, which a release that waits for a merge's table on a slow link does not, in this release as in those before it.
- The third found that a merge still failed when a claim check of a flush it gave way to met a store that failed for a second, which on a link that resets is the most likely failure; that the runs were counted while the merge's result was published and collected, when no merge was under way; that a merge's read looked for a release only between its attempts, and not while a call was under way, nor when the database closed for a takeover; and that the size soak counted writes that were told to wait as written.
- The fourth found that a merge stopped by a release warned of a storage failure, that a store's refusal for good was gone on past at every table, and that the soak went on past a server that died in its write load. The fifth found that a release still warned through a merge behind a merge, since a read it stopped came as a failure of the store and was gone on past; the sixth, that with a disk cache a release waits for the merge's table, as the documentation says, and that two tests could be sharper, which they were made.
scripts/soak-size.shwith 2.1.8 and then 2.1.9, the morning 2.1.9 was released, on a local directory at 4 GiB and on Backblaze at 1 GiB with 64 and with 256 clients (performance): the two were within what one run differs from the next, and no request failed. None of those fills came to 24 runs, 20 at most, so none shows the bound: the link carried 2.9 to 4.7 MB a second up, and a database takes no more writes than it can flush, which held 256 clients to some 340 commits a second, told to wait some 450,000 times. The bound is shown by the tests. One run of 2.1.9 with 256 clients was read more slowly than 2.1.8's after its first minute, 40 keys a second where 2.1.8 read 77: the merge that the server opening it began, of the runs that were too many, had not ended when its scans did. A run of it again, with its runs sampled every ten seconds and its server's log kept, which is not the script as published, read 16 and then 90 keys a second; that merge ended after a minute and forty seconds, and the log had no warning.The protocol and the storage format are unchanged. Fifteen tests in
tests/interleavings.rsand one insrc/io.rsare new, and the chaos test asks again for a transaction refused before it was given a revision; 28 faults put into the change one at a time each fail a test, and the 49 of finding 44 and the 92 of finding 43 still do. The suite is run with eight test threads on 2.3 processors as well, the shape of the build machines, where a test of finding 41 had failed once in twelve runs before 2.1.8 was released.What remains. A database whose merges fall behind its writes is held to some 24 runs while it merges, and each of them is a request for a read of a key that is in neither cache. One that waits for one of a server's two turns to merge is not held back, and gains runs until it has its turn. A merge that fails every time, as on a damaged table, is begun again for every write that is taken. A release waits for a merge to stop, at its next read or after the upload of the table it is writing; on a slow link that upload is a minute or more, and a server killed then leaves its claim to be revoked and its log to be read again by the next owner. The figure of 24 was chosen, not measured against others.
- While a merge is under way, a write is answered
-
A database that waited for a turn to merge gained a run with every flush, and a release waited for the upload of a merge's table. Both were stated as limits of 2.1.9 (finding 45). A server merges two databases at a time, and a merge held its turn from its first table to its last: for a database of 4 GiB, half a minute on a local directory and far longer over a bucket. A third database whose merge was due waited for the whole of it, took writes, and gained a run with each flush, which every read of it looks in; it was not held to the bound of finding 45, which applies only while a database merges. And a release or a deletion waited for the merge to stop after the upload of the table it was writing, a minute or more on a slow link, which is longer than the grace of the Kubernetes manifest.
Since 2.1.10:
- A merge gives its turn to a database that waits for one between two of its tables, and waits for a turn again. While more databases have a merge to make than there are turns, their merges take turns a table at a time. A merge that waits for its turn flushes what falls due, is use, and holds where it is in each run and no more: not what it had read ahead, nor any index. Its database takes writes as one that waits to begin a merge does, and counts the merge's runs again once it has its turn. A merge behind a merge has no turn of its own to give.
- A merge no longer holds the index of a run it has read through.
- A release or a deletion does not wait for the upload of a merge's table. The upload goes on alone, one attempt at a time, and deletes what it stored once it ends. No merge is begun once a release has, including after the flush that a merge for the quota makes first.
Three readings by a reviewer that had not written the change, before it was released. None found a table that a manifest lists deleted, a turn lost or held twice, or anything else that answered wrong; each found something that was changed.
- The first found that a merge that waited for its turn again still counted as merging, so that its database refused writes that nothing would merge meanwhile; that a merge's small tables were raced as a flush's are, so that a release waited up to ten seconds for their attempts, and one could land after the upload had deleted what it stored and stay in a database that had been deleted; that an upload was begun after a release had; that a merge that waited held an index and a block of each of its runs, and that any number of merges might wait; and that two tests passed without the code they were written for.
- The second found that nothing pinned that a merge counts its runs again once it has its turn; and that a merge could begin after a release had, after the flush that the maintenance makes, read all it needed from the disk cache, where a release stops nothing, and upload its table. And that a request the store applies after it reported it failed may land after the upload's delete, as it may for any upload.
- The third found the same of the flush that a merge for the quota makes first.
After the release, a reading of a later change found that a database whose turn was granted while it flushed could take the other turn for its merge, and leave the one it was granted unused for as long as that merge ran: a turn kept from others, and nothing answered wrong. The first fix looked for a granted turn before a merge for the quota flushed what had not been flushed, and a reading of 2.1.11 before its release found the same thing could happen during that flush; its waiting then counted as a database that waits, and the merge would have given its own turn up at every table. Since 2.1.11 a database in line for a turn takes no other, and looks for the one it was granted after any flush.
a_turn_granted_during_a_flush_is_the_one_a_merge_takesintests/interleavings.rsfails without it, anda_database_keeps_its_place_in_line_while_it_flushesfails if a database that is woken before its turn has come leaves the line.Two checks that the first form added were taken out: one that a merge begins no upload once a release has, and one that a merge that has its turn again as a release begins goes no further. With them, two faults of finding 44, which take out the checks that stop a merge after a release, no longer failed a test, since such a merge then stored nothing either way, and no test could tell either check from its absence.
scripts/soak-tenants.shwith 2.1.9 and then 2.1.10, one run of each, the afternoon 2.1.10 was released, on a local directory (performance). While two merges of 4 GiB held the server's turns, a small database written by 64 clients went from 2 runs to 27 with 2.1.9 and was read at 45,580 keys a second at the least; with 2.1.10 it had 5 runs at most and was read at 114,316 at the least. The two merges took a tenth longer, 52.5 seconds where they had taken 47.5 and 48.3. Three merges of 2 GiB, which 2.1.9 ended after 24.5, 25.3 and 42.7 seconds, 2.1.10 ended after 37.7 to 38.6.The protocol and the storage format are unchanged. One object is deleted outside the rule the model checks: the table of a merge whose upload a release, a deletion or a takeover stopped waiting for, by that upload, whatever claim its server holds by then. No manifest lists it or can come to (model). Twelve tests in
tests/interleavings.rsare new, one of them the disk-cache test of what a merge is coming to with the flush made while the merge waits for its turn, and two were changed; a test intests/engine.rswaits for merges to end before it counts the indexes in memory, since a merge holds those it reads. 25 faults put into the change one at a time each fail a test, and the 29 of finding 45, the 49 of finding 44 and the 92 of finding 43 still do.What remains. While more databases have a merge to make than a server has turns, their merges take turns a table at a time, and each takes longer than with a turn to itself: the first two of three merges of 2 GiB ended thirteen seconds later. A merge that gives its turn up reads again what it had read ahead and the indexes of its tables, which on a bucket is download; that has been measured on a local directory and not on a bucket. A merge that reads all it needs from the disk cache when a release begins goes on to the end of its table, uploads it in the background and deletes it. A request that the store applies after it reported it failed may land after that upload has deleted its table, and stay. Writes wait while a merge would leave a database with more than 24 runs, a figure chosen and not measured against others, and a merge that fails every time is begun again for every write that is taken.
-
On a store that was slow to list, collection stopped, and it held its database's flushes meanwhile. Stated as a limit of 2.1.11. In
scripts/soak-bucket.sh, 256 databases written at once on a MinIO in a container on the desktop, every purge failed from about the seventh minute until the writes ended, in every run of 2.1.10 and 2.1.11 that counted them, and what the store kept grew threefold in the one run that measured it. MinIO answered. One listing of a database's frames every thirty seconds, waited for as long as it took, took from 23 to 84 s from the eighth minute until the writes ended, and milliseconds before and after; on the same MinIO idle, a listing of a thousand versions takes 40 ms whether a thousand or ten thousand objects are under the prefix. But each request of a purge was given up at twenty seconds, the patience of every request, and sent again, twice, and a purge whose request is not answered three times fails; the next purge asked the same. A collection ran inside its database's maintenance, so each purge that failed held that database's next flush for a minute.A change that was tried first and not released: a purge that asked for a quarter as many keys after each request that went unanswered, down to sixteen. In the same soak its purges began to fail at the eleventh minute, and then every one did. Asking for fewer is not what that store needed.
Since 2.1.12:
- A request of a purge waits up to two minutes for the first byte of its answer. Every other request waits twenty seconds, as before.
- A collection runs in a task of its own, one at a time for a database, and the flush or merge that published waits for it five seconds at most. What comes due while one runs it collects after what it began with, and the flags that say so are kept under the lock of what is due. It gives way to a release or a deletion at once, as since 2.1.6. The sweep of what earlier epochs left runs the same way.
- A release waits half a minute at most for what it leaves to be collected, and as long for the old versions of its claim to be removed; the next owner's sweep removes what is left. A deletion waits seven minutes at most for the store to remove the database's objects, as long as it could before, and says to repeat it if they are not all removed by then.
It is safe for a collection to go on by itself, and for its requests to arrive after its database was released and taken by another owner, because what it deletes no later epoch needs. The model now checks that: in
LateDeletes, a collection's DELETE takes effect at any later time, any number of times (the model).Five tests hold single requests for it: a flush made while a collection's purge is held, and the collection of what came due meanwhile and after it; a flush made while a new owner's sweep is held; a release that ends within a minute when no purge is answered, half for what it leaves and half for its claim; a deletion that ends within seven minutes when no purge is answered, and is finished when it is repeated; and in
src/store/s3.rsa purge answered after the patience of a listing and before its own, when it lists versions, when it lists keys, and when it removes them. Eleven faults put into the change one at a time each fail one of them; two did not until the tests were made to look further, a removal that waited twenty seconds and a collection that ended without saying so. A reading of the change by a reviewer that had not written it found nothing that deletes what an owner needs, and asked for three changes, all made: the flags kept under the lock of what is due, where two of them could each miss the other's change and leave one flush's collection to the next; the sweep run the same way, where each of its requests would otherwise have held the flushes for two minutes; and the bound on a deletion's wait, which would otherwise have been forty minutes.The soak with a build of this change before those three, with nothing else running but a reader of the server's counters and, for two minutes, a build at the lowest priority: 1,229 commits a second and none failed; 533 MiB at most; 8,385 purges while the databases were written and none failed, the last of them taking up to two minutes each; and the 256 deletions took 131 s, the slowest 93 s, where with 2.1.11 they took 1,179 and 268 s. That run of 2.1.11 made 1,580 commits a second, and two others the same morning 1,246 and 1,286: whether collecting while writing costs that store some of its writes was not settled.
The soak with the binary of 2.1.12: 1,230 commits a second and none failed; 517 MiB at most; no purge failed until the thirteenth minute, and then MinIO took longer than two minutes over some listings: no purge was made from then until the writes ended, 256 of 5,976 failed after six minutes each, and the 256 deletions took 363 s, the slowest 286 s. Collection went on six minutes longer into the load than with 2.1.11, and in the run before throughout it; a store slower than two minutes still stops it.
What has been run where#
| Storage | Unit, engine, chaos | HTTP, cluster | Bucket tests | Benchmarks | Kubernetes |
|---|---|---|---|---|---|
| Memory | yes | ||||
| S3 stand-in (in process) | storage tests only | ||||
| Local directory | yes | yes | yes | ||
Backblaze B2 (us-west-002) |
yes | yes | yes (kind) | ||
| MinIO (a community build), RustFS, Garage: one process each, in a container | yes | the ledger; on MinIO 256 databases for twenty minutes, and one database of 4 GiB | |||
| Amazon S3, Cloudflare R2, Google Cloud Storage | not yet | not yet | not yet |
What Amazon S3 and Google Cloud Storage answer to listings without an account has been read from public buckets (finding 35). That is not a run: durable-db has stored nothing on either.
Remaining obligations#
- Send the request that removes many versions to Amazon S3, to Google Cloud Storage and to a store that refuses it. It has been sent to Backblaze B2, a community build of MinIO, RustFS and Garage, which all take it, and to a stand-in that refuses it.
- Run the bucket tests and benchmarks on Amazon S3, Cloudflare R2 and Google Cloud Storage. The code path is shared with B2 except for the upload call, and has been run on three S3 servers that were each one process on one machine, which says nothing of a provider's consistency across its own machines. What Amazon and Google answer without an account is in finding 35. R2 answers nothing without one: its documentation lists the request that lists versions as not implemented, and what it answers to that request, which decides whether a server starts there, has been read about and not seen. On Google Cloud Storage a bucket's soft delete, which Google's documentation gives as on for a new bucket, keeps what is removed for seven days more; whether a purge is then complete has not been tried.
- A soak of many hours under load with periodic failures, on a real multi-node cluster rather than kind. What has been run is half an hour on one desktop with a server stopped every ten seconds (
scripts/soak-kills.sh). - The memory soak for hours, and on a provider's bucket, where an upload stays in memory for as long as the bucket takes to store it. On a local directory it has run for ten minutes a load, and on MinIO on the same desktop for twenty minutes of 256 databases and once for an hour (
scripts/soak-bucket.sh, finding 39): memory was level in each. In the hour collection did not keep up with that MinIO, two purges in three failing, and the deletions after it had not ended in 57 minutes. On Backblaze B2 with the default flags it was still rising after eleven minutes (finding 37). - A store that is slow holds up more than the request that waits for it, within bounds since 2.1.12 (finding 47): a purge waits two minutes for each answer, a flush waits five seconds for a collection, a release half a minute for its own, and a deletion seven minutes for the store, after which it says to repeat it. A store that answers a purge in more than two minutes still gets no collection done, and nothing bounds what is left until it answers in time.
- Which tables a disk cache smaller than what its server reads should hold. It keeps those that were read in the last five minutes, whichever came first, and does not count how often each is read; a server that writes much through such a cache fetches again what its writes put out. Neither has been measured under a load that changes.
- One database larger than 1 GiB on a provider's bucket, larger than 16 GiB anywhere, or larger than its server's disk cache on a bucket. What a write at the quota waits for, a merge of everything, has been timed over one desktop's uplink only.
- Model the receipt window after which a retry is applied again, and a revocation's DELETE, a release's or a deleted database's purge that arrives late.
- Check a liveness property: with one correct server and working storage, a request is eventually answered.
- Make the chaos test repeatable from its seed alone, by giving the engine the simulated clock for its deadlines, and run it routinely under CPU pressure as well as without.
- The rule for choosing storage pods on Backblaze B2 was measured from one desktop on Wi-Fi, for minutes at a time. A server in a data centre, and hours of load, have not been measured.
- A server sends requests as fast as its databases commit and keeps itself under no rate. It holds back from a store that refuses everything of one kind (findings 38 and 39), which has been seen on stand-ins and behind a proxy and not on Backblaze B2, whose refusal (finding 37) was not made again. What Backblaze answers then, with which code and
Retry-After, has not been read. - A round of a server's housekeeping that does not end is reported every thirty seconds since 2.1.6, and nothing takes its place: it is not ended, since what it holds is not known. The one that was long waited for releases, which none does now (finding 40).
- Over a slow link, merges that take turns (finding 46) cost the large ones half as long again and more: two merges of 1 GiB at their quotas took 909 and 986 s, where with 2.1.9 they took 457 and 650, while a small database written meanwhile had 18 runs at most where it had 48 (performance). Giving the turn only to a database that needs it, one with more runs than it may keep, was tried in three forms and did no better over that link: a database written steadily goes back above twelve runs at almost every flush, and then needs the turn again. A bound on how often one merge gives its turn up, once in four of its tables, was tried next, chosen with a test in memory whose cost was what a merge reads again, and over the slow link it did no better either. Runs a quarter that size, through a disk cache a quarter as large as before, show how far one run is from the next (performance): two of the code on
mainafter 2.1.10, which merges as 2.1.10 does, took 154 and 210 s and then 131 and 109 s, where one of 2.1.9 took 128 and 127 s. The server's log of each merge shows both costs of turns: the small database's own merges, which in the first run stored 244 MiB while the writes at the quotas waited and in the second 89 MiB, and what the large merges read again, 826 and then 408 MiB read back from storage. Waiting does not save the small database's merges, only puts them off and makes one of them larger, and a merge of many runs at once sends less than many of fewer. Several runs of each release are needed to say how much turns cost over a slow link, and a rule that sends less, as merges that take more runs at once, would change what every read looks in, everywhere. - Writes wait while a merge would leave more than 24 runs (finding 45). Over a slow link it was not reached, and a bound of 12 held writes back without holding the runs down (performance); how often a database on a provider's bucket reaches it has not been measured. Merges that take turns a table at a time (finding 46) have been measured on a local directory and not on a bucket, where what a merge reads again after giving its turn up is download.
- A review by people outside the project. The reviews recorded above were automated and commissioned by the project itself.
- Behaviour when the bucket itself misbehaves beyond the assumptions (lost objects, stale listings) is undefined; block checksums detect corrupted table data only, and a manifest carries no checksum of its own.