<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alex E</title>
    <description>The latest articles on DEV Community by Alex E (@alexander-efremov).</description>
    <link>https://dev.to/alexander-efremov</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3972169%2Fdeba24d7-a7da-4581-9c60-30514773514c.png</url>
      <title>DEV Community: Alex E</title>
      <link>https://dev.to/alexander-efremov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexander-efremov"/>
    <language>en</language>
    <item>
      <title>Why Squirix shed its web stack</title>
      <dc:creator>Alex E</dc:creator>
      <pubDate>Mon, 23 Nov 2026 14:33:15 +0000</pubDate>
      <link>https://dev.to/alexander-efremov/why-squirix-shed-its-web-stack-2p0n</link>
      <guid>https://dev.to/alexander-efremov/why-squirix-shed-its-web-stack-2p0n</guid>
      <description>&lt;h1&gt;
  
  
  Why Squirix shed its web stack
&lt;/h1&gt;

&lt;p&gt;The first versions of Squirix, a distributed cache for .NET, ran as an ASP.NET Core app. Kestrel accepted connections, and a shared &lt;code&gt;.proto&lt;/code&gt; file told the C# client and server how to talk to each other over gRPC. That saved me time when I was working out which replica could safely acknowledge a write.&lt;/p&gt;

&lt;p&gt;For &lt;code&gt;0.2.0-preview.1&lt;/code&gt;, I wanted to look at a cheaper operation: reading a short string that's already in memory. Even on a cache hit, the server has to decode the request, look up the key and send the value back. I wanted to be able to change how Squirix did that last part, right down to when it flushed the connection.&lt;/p&gt;

&lt;p&gt;The change happened in stages. For a while, Squirix was running a binary protocol over TLS, hosted by Kestrel, with Protobuf still encoding the messages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four reads on one connection
&lt;/h2&gt;

&lt;p&gt;The SDK was the first piece to move off gRPC. Consider what happens when four small reads finish on the same connection. If all four replies are ready, the server can write them into the output buffer and flush once. If only one is ready, it can go out on its own. There's no timer holding up that first reply in case another one comes along.&lt;/p&gt;

&lt;p&gt;There was still gRPC traffic inside the cluster. Nodes used it to talk to each other even after the SDK had switched protocols. Moving that traffic to a separate binary connection with mutual TLS removed the remaining server-side gRPC dependency. It also changed the upgrade procedure: all nodes in a cluster have to switch together.&lt;/p&gt;

&lt;h2&gt;
  
  
  What replaced Kestrel
&lt;/h2&gt;

&lt;p&gt;At that point Squirix still started as a web application. In &lt;code&gt;0.2.0-preview.1&lt;/code&gt;, the node opens its own sockets and uses .NET's &lt;code&gt;SslStream&lt;/code&gt; for TLS. The SDK connects to one listener and cluster peers connect to another. Health checks and Prometheus metrics still use HTTP/1.1 over TLS, on a separate management address.&lt;/p&gt;

&lt;p&gt;Dropping the ASP.NET Core shared framework took more work than replacing the listener. The node now starts and stops its own background workers, manages service lifetimes and handles logging. Its readiness checks cover journal recovery and replica state. Bearer-token validation also moved out of ASP.NET Core's JWT middleware.&lt;/p&gt;

&lt;p&gt;One place you can see the difference is the Dockerfile. The final server image uses &lt;code&gt;dotnet/runtime:10.0.15&lt;/code&gt;. You can also start a node inside a console app with &lt;code&gt;SquirixServer.StartAsync&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If your own application uses ASP.NET Core, you can still connect through &lt;code&gt;IDistributedCache&lt;/code&gt;. The integration package keeps the Microsoft abstractions the application needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a cache miss looks like on the wire
&lt;/h2&gt;

&lt;p&gt;After the move to sockets, the SDK and server still used Protobuf. I later removed the cache and replication &lt;code&gt;.proto&lt;/code&gt; files, the gRPC build tools and the &lt;code&gt;Google.Protobuf&lt;/code&gt; runtime. Squirix now has its own codec for cache requests and replies.&lt;/p&gt;

&lt;p&gt;Take &lt;code&gt;GetValueAsync&lt;/code&gt;. For a small reply, the server writes an eight-byte header containing the request ID, status and body length. When a lookup succeeds but the key is missing, the body length is zero. Those eight bytes are the whole cache reply before TLS framing.&lt;/p&gt;

&lt;p&gt;When the key holds a small value, the writer reserves room in the output pipe for the header and the encoded response body. It writes both into that space. This step needs no temporary byte array for the encoded reply.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the allocation numbers tell us
&lt;/h2&gt;

&lt;p&gt;During the migration, three CI runs on Ubuntu with .NET 10 measured managed allocations for calls through the public SDK. These two cases read and wrote short strings against one node with persistence off.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;Previous CI budget&lt;/th&gt;
&lt;th&gt;Average across three runs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Read a value&lt;/td&gt;
&lt;td&gt;10,530 B/op&lt;/td&gt;
&lt;td&gt;3,217 B/op&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Write a value&lt;/td&gt;
&lt;td&gt;11,780 B/op&lt;/td&gt;
&lt;td&gt;3,787 B/op&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The server was already using the binary transport when CI recorded those numbers. It still used Protobuf. The left column is the previous allocation budget, so the table records why I could lower that budget. It doesn't tell me how much time the codec change saved on a read. To answer that, I'd time a complete SDK call with one read in flight, then repeat with several reads sharing a connection.&lt;/p&gt;

&lt;p&gt;I’d use gRPC again for an early version of a project like this. It let me work on replication while the cache was taking shape. In Squirix today, I want to be able to change how a cache miss is encoded and when a reply goes out. Owning the protocol gives me that control. It also makes a client disconnecting halfway through a frame my problem to handle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.2.0-preview.1/docs/release-notes/v0.2.0-preview.1.md" rel="noopener noreferrer"&gt;Release notes and upgrade details&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.2.0-preview.1/src/squirix.server/Adapters/Endpoint/BinaryConnectionPump.cs" rel="noopener noreferrer"&gt;The server loop that writes and flushes replies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/pull/1836" rel="noopener noreferrer"&gt;The binary codec change&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.2.0-preview.1/benchmarks/ci-baselines.md" rel="noopener noreferrer"&gt;Allocation budgets, methodology and CI runs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Originally published on the &lt;a href="https://squirix.io/blog/why-squirix-shed-its-web-stack/" rel="noopener noreferrer"&gt;Squirix blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>caching</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Squirix preview.10: batching replicated writes</title>
      <dc:creator>Alex E</dc:creator>
      <pubDate>Mon, 09 Nov 2026 00:00:00 +0000</pubDate>
      <link>https://dev.to/alexander-efremov/squirix-preview10-batching-replicated-writes-2pn0</link>
      <guid>https://dev.to/alexander-efremov/squirix-preview10-batching-replicated-writes-2pn0</guid>
      <description>&lt;p&gt;Suppose two clients write different keys that belong to the same replica group. Both requests reach the same leader. In Squirix &lt;code&gt;0.1.0-preview.10&lt;/code&gt;, it can send both writes to its followers in a single batch.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://squirix.io/blog/who-is-the-leader/" rel="noopener noreferrer"&gt;preview.9 article&lt;/a&gt; covered leader election and fencing. Preview.10 changes how the leader handles concurrent writes.&lt;/p&gt;


&lt;p id="article-toc-label"&gt;On this page&lt;/p&gt;
&lt;br&gt;
  &lt;ul&gt;

    &lt;li&gt;&lt;a href="https://squirix.io/blog/squirix-preview-10/#one-batch-several-writes" rel="noopener noreferrer"&gt;One batch, several writes&lt;/a&gt;&lt;/li&gt;

    &lt;li&gt;&lt;a href="https://squirix.io/blog/squirix-preview-10/#when-a-write-is-retried" rel="noopener noreferrer"&gt;When a write is retried&lt;/a&gt;&lt;/li&gt;

    &lt;li&gt;&lt;a href="https://squirix.io/blog/squirix-preview-10/#before-you-upgrade" rel="noopener noreferrer"&gt;Before you upgrade&lt;/a&gt;&lt;/li&gt;

    &lt;li&gt;&lt;a href="https://squirix.io/blog/squirix-preview-10/#links" rel="noopener noreferrer"&gt;Links&lt;/a&gt;&lt;/li&gt;

  &lt;/ul&gt;

&lt;h2&gt;
  
  
  One batch, several writes
&lt;/h2&gt;

&lt;p&gt;The leader can append and replicate several ready writes together. Each request still gets its own result, and in a group of three or more nodes, the server reports success only after a majority commits the write. Your application still calls &lt;code&gt;SetAsync&lt;/code&gt; for each write.&lt;/p&gt;

&lt;h2&gt;
  
  
  When a write is retried
&lt;/h2&gt;

&lt;p&gt;A write can commit just before the connection drops, leaving the client without a response. When the SDK automatically retries a write, it resends the request with the original operation ID, even if it switches to another node. If the request matches and the group still has the original result, it returns that result without applying the write again.&lt;/p&gt;

&lt;p&gt;Preview.10 improves retention of those results during the retry window. Calling the SDK again yourself creates a new operation ID. If the server reports &lt;code&gt;COMMIT_OUTCOME_UNKNOWN&lt;/code&gt;, the SDK throws &lt;code&gt;CommitOutcomeUnknownException&lt;/code&gt; without retrying. See the &lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.10/docs/api.md" rel="noopener noreferrer"&gt;API documentation for preview.10&lt;/a&gt; for the retention and clock assumptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you upgrade
&lt;/h2&gt;

&lt;p&gt;Preview.10 requires .NET 10. If you mix preview.9 and preview.10 nodes, the cluster fails its readiness checks. Preview.10 also rejects older replica-group metadata and data directories activated by earlier cluster builds. For a disposable test cluster, start with empty directories. For an existing cluster, keep a backup and follow the &lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.10/docs/operational-runbook.md#upgrade" rel="noopener noreferrer"&gt;upgrade runbook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you host the server in your own .NET process, import &lt;code&gt;ExtensionOptions&lt;/code&gt; from &lt;code&gt;Squirix.Server.Node.Hosting&lt;/code&gt;. The &lt;a href="https://github.com/squirix/squirix/releases/tag/v0.1.0-preview.10" rel="noopener noreferrer"&gt;preview.10 release notes&lt;/a&gt; also cover journal and snapshot I/O, client allocations, and recovery after a forwarding connection fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/releases/tag/v0.1.0-preview.10" rel="noopener noreferrer"&gt;Release &lt;code&gt;v0.1.0-preview.10&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.10/docs/api.md" rel="noopener noreferrer"&gt;Client API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.10/docs/consistency.md" rel="noopener noreferrer"&gt;Consistency&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.10/docs/operational-runbook.md#upgrade" rel="noopener noreferrer"&gt;Upgrade runbook&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Install the standalone CLI for preview.10:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet tool install --global squirix.server.tool --version 0.1.0-preview.10

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>dotnet</category>
      <category>distributedsystems</category>
      <category>csharp</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Operating a replica set: opt-in, metrics, and an RF=3 Docker demo in Squirix preview.9</title>
      <dc:creator>Alex E</dc:creator>
      <pubDate>Sat, 31 Oct 2026 03:37:41 +0000</pubDate>
      <link>https://dev.to/alexander-efremov/operating-a-replica-set-opt-in-metrics-and-an-rf3-docker-demo-in-squirix-preview9-4p19</link>
      <guid>https://dev.to/alexander-efremov/operating-a-replica-set-opt-in-metrics-and-an-rf3-docker-demo-in-squirix-preview9-4p19</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/alexander-efremov/from-one-owner-to-a-replica-set-synchronous-replication-in-squirix-preview8-3jmd"&gt;Part 1&lt;/a&gt; covered synchronous majority commit and catch-up. &lt;a href="https://dev.to/alexander-efremov/who-is-the-leader-elections-fencing-and-why-rf2-cant-fail-over-in-squirix-preview9-2dkn"&gt;Part 2&lt;/a&gt; covered elections, fencing, and why RF=2 cannot fail over.&lt;/p&gt;

&lt;p&gt;There is a third question before any of that becomes useful: how does an operator turn it on, tell whether it is working, and check what happens when a leader dies?&lt;/p&gt;

&lt;p&gt;That question matters especially after &lt;a href="https://dev.to/alexander-efremov/-the-failover-test-that-stopped-the-wrong-node-4ej2"&gt;the failover test that stopped the wrong node&lt;/a&gt;. Preview.8 had replication, but its election code was not wired into the server. Preview.9 connects it. Three copies alone do not mean automatic failover.&lt;/p&gt;

&lt;p&gt;This final part uses &lt;code&gt;0.1.0-preview.9&lt;/code&gt;: explicit switches, persistence and mTLS prerequisites, topology checks, live metrics, and the RF=3 Compose example. Squirix remains experimental software. Its APIs, wire format, and storage formats may change during &lt;code&gt;0.x&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three copies are not an HA switch
&lt;/h2&gt;

&lt;p&gt;Setting &lt;code&gt;ReplicaCount&lt;/code&gt; to three chooses how many copies hold a key. It does not enable durable storage, grant permission to replicate, or turn on elections.&lt;/p&gt;

&lt;p&gt;Replication has its own opt-in: &lt;code&gt;Squirix:Cluster:ReplicationEnabled&lt;/code&gt;, default &lt;code&gt;false&lt;/code&gt;, or the standalone-host flag &lt;code&gt;--enable-replication&lt;/code&gt;. RF&amp;gt;1 without it refuses startup. RF&amp;gt;1 also requires persistence and inter-node mTLS. Automatic failover adds two settings, both off by default: &lt;code&gt;AutomaticFailoverEnabled&lt;/code&gt; and &lt;code&gt;QuorumReadsEnabled&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is the relevant fragment of a settings file; node identity, peers, and certificate configuration still need to be supplied:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Squirix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Cluster"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"ReplicaCount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"PersistenceEnabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"ReplicationEnabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"AutomaticFailoverEnabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"QuorumReadsEnabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Validation requires the last two switches together and refuses them for RF=1 or RF=2. With both off, replication works, but losing a key's owner makes its keys unavailable until that owner returns. With both on, a surviving majority can elect a replacement, and reads confirm authority with a quorum.&lt;/p&gt;

&lt;p&gt;Every node must agree on these settings. The failover switches are part of the topology fingerprint and must be chosen when the cluster is created, on empty data directories. They have no CLI flags; &lt;code&gt;--enable-replication&lt;/code&gt; alone does not enable failover.&lt;/p&gt;

&lt;p&gt;With a complete settings file and the cluster mTLS environment configured, the standalone commands are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;squirix-server validate-config &lt;span class="nt"&gt;--settings&lt;/span&gt; ./Squirix.settings.json &lt;span class="nt"&gt;--strict&lt;/span&gt;
squirix-server run &lt;span class="nt"&gt;--settings&lt;/span&gt; ./Squirix.settings.json &lt;span class="nt"&gt;--persist&lt;/span&gt; &lt;span class="nt"&gt;--data-dir&lt;/span&gt; ./data &lt;span class="nt"&gt;--enable-replication&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configuration validation catches invalid settings. It does not prove that peers are reachable or that the cluster can elect a leader. That needs a running cluster and a failure test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two listeners, two kinds of identity
&lt;/h2&gt;

&lt;p&gt;Application clients authenticate with JWT on the primary HTTPS listener. Replication uses the internal mTLS listener, a cluster CA, and node certificates whose &lt;code&gt;CN&lt;/code&gt; matches &lt;code&gt;NodeId&lt;/code&gt;. An application's JWT is not a replication identity.&lt;/p&gt;

&lt;p&gt;If a node certificate lists extended key usages, both &lt;code&gt;serverAuth&lt;/code&gt; and &lt;code&gt;clientAuth&lt;/code&gt; must be allowed. Certificate chains are built without network downloads: required intermediates must be in the configured CA bundle or the OS store.&lt;/p&gt;

&lt;p&gt;In Compose, host clients use &lt;code&gt;https://localhost:5001&lt;/code&gt;, &lt;code&gt;:5002&lt;/code&gt;, and &lt;code&gt;:5003&lt;/code&gt;. Each maps to the primary listener on container port &lt;code&gt;5000&lt;/code&gt;. Peer URIs use Docker service names and that same primary port, for example &lt;code&gt;https://squirix-node-a:5000&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The transport derives the internal endpoint by substituting the configured mTLS port, &lt;code&gt;5100&lt;/code&gt; in the example. Actual internode traffic goes there. Putting &lt;code&gt;5100&lt;/code&gt; in &lt;code&gt;Peers[].Uri&lt;/code&gt; instead changes the peer identity the topology expects. Each node's &lt;code&gt;Cluster.Uri&lt;/code&gt; must match its own peer entry.&lt;/p&gt;

&lt;p&gt;One address lets a host client reach the node, another identifies the peer in the topology, and the internal transport endpoint is derived from it.&lt;/p&gt;

&lt;h2&gt;
  
  
  A restart does not authorize a new topology
&lt;/h2&gt;

&lt;p&gt;RF&amp;gt;1 activation writes a topology stamp into the data directory. Later starts compare the configured topology with that stamp. A different replica count, peer set, configuration generation, or failover setting is not silently accepted over the existing replica logs.&lt;/p&gt;

&lt;p&gt;The fingerprint also includes the minimum cluster package version and replication policy constants. The supported cluster uses one homogeneous build; mixed versions are not a rolling-upgrade strategy. A changed fingerprint can prevent a new version from starting on an old RF&amp;gt;1 directory even after every node has been upgraded.&lt;/p&gt;

&lt;p&gt;Before an upgrade, check the release-specific migration instructions and run the target version's &lt;code&gt;doctor&lt;/code&gt; against a backup copy of the data, using the intended settings and mTLS environment. Do not edit or delete &lt;code&gt;topology.stamp&lt;/code&gt; to make a mismatch disappear: the group logs still belong to the old topology.&lt;/p&gt;

&lt;p&gt;For a disposable local demo, fresh volumes provide a fresh start. For data you need to keep, deleting the volumes is data loss, not migration.&lt;/p&gt;

&lt;p&gt;Preview.9 specifically changes key placement to XxHash64 and changes journal, manifest, snapshot, and replica-group storage formats. Preview.8 data directories, including RF=1, do not start under preview.9. There is no in-place format migration for this upgrade; use the release's full-cluster restart and empty-directory procedure with a data reload plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start every member before waiting for readiness
&lt;/h2&gt;

&lt;p&gt;The first activation of a fresh replica group needs every configured member, not just a majority. The original owner checks the other copies, offers each a place in the group, and completes its own copy only after all accepted. Until activation completes, the affected keys refuse service and the unseeded copies fail readiness.&lt;/p&gt;

&lt;p&gt;Start all members before waiting for them to become ready. An orchestrator that waits for node A's readiness before starting B and C can prevent the initial group from activating. This first-start requirement is different from an activated RF=3 group continuing on two survivors after a failure.&lt;/p&gt;

&lt;p&gt;A returning member on an empty disk is unseeded and cannot vote or accept ordinary appends. A surviving leader repairs it with state transfer; its empty copy is not permission to create a competing group.&lt;/p&gt;

&lt;h2&gt;
  
  
  Readiness answers less than you might expect
&lt;/h2&gt;

&lt;p&gt;The host exposes &lt;code&gt;/health&lt;/code&gt;, &lt;code&gt;/health/live&lt;/code&gt;, &lt;code&gt;/health/ready&lt;/code&gt;, &lt;code&gt;/health/ready/details&lt;/code&gt;, and Prometheus metrics at &lt;code&gt;/metrics&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Readiness catches conditions such as unfinished journal recovery, a failed journal pipeline, or a detected ring mismatch. It is not a promise that every replica group can commit. A lagging follower or a growing group log does not, by itself, make &lt;code&gt;/health/ready&lt;/code&gt; unhealthy. Journal disk quota can reject writes while readiness stays healthy.&lt;/p&gt;

&lt;p&gt;Replica readiness does reject an unready log, an unseeded or incomplete local copy, a topology mismatch, a stale term, or a leader fenced for missing majority contact. A healthy follower does not need leader authority to pass its own readiness check. Readiness is therefore local admission information, not a substitute for a group-level write probe.&lt;/p&gt;

&lt;p&gt;The details payload adds &lt;code&gt;replicaGroups&lt;/code&gt;: log size, retained entries, snapshot index, and the leader's view of its other copies. Their states are &lt;code&gt;recovering&lt;/code&gt;, &lt;code&gt;catching-up&lt;/code&gt;, or &lt;code&gt;ready&lt;/code&gt;; only &lt;code&gt;ready&lt;/code&gt; copies count toward the write quorum. The copy list is empty on followers and before a leader's commit coordinator has started.&lt;/p&gt;

&lt;p&gt;For live replication, these are the first metrics I would inspect:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;What it tells you&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;squirix_replication_role&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Per-group role: &lt;code&gt;0&lt;/code&gt; follower, &lt;code&gt;1&lt;/code&gt; pre-candidate, &lt;code&gt;2&lt;/code&gt; candidate, &lt;code&gt;3&lt;/code&gt; leader awaiting its term commit, &lt;code&gt;4&lt;/code&gt; leader with authority.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;squirix_replication_leader_authority&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Whether this node leads the group and holds write authority.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;squirix_replication_quorum_available&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Whether a ready majority exists. Writes also need leader authority.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;squirix_replication_lag_entries&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Peer lag according to the leader's latest verified information.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;squirix_replication_unknown_commit_total&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Commits whose outcome was unknown after the local append.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;squirix_replication_state_transfers_total&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;State-transfer attempts and declined captures, with outcome and reason labels.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Leadership is per group. A node can lead one group and follow another. The leader reports peer lag; a follower does not supply the same peer series. Some gauges are refreshed by the readiness probe, so keep that probe running alongside the metrics scrape.&lt;/p&gt;

&lt;p&gt;Even a quorum gauge at &lt;code&gt;1&lt;/code&gt; deserves context: in RF=3 with one copy down, two ready members can commit, but the group has no remaining failure margin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doctor reads the disk; metrics describe the running group
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;doctor&lt;/code&gt; does not contact the cluster to prove a live quorum exists. It reads the configured topology, the data directory's activated stamp, and durable replica metadata, without starting the node. It can also inspect metadata while a node is running.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;squirix-server doctor &lt;span class="nt"&gt;--settings&lt;/span&gt; ./Squirix.settings.json &lt;span class="nt"&gt;--persist&lt;/span&gt; &lt;span class="nt"&gt;--data-dir&lt;/span&gt; ./data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its report includes the fingerprint, configuration generation, and per-group term, commit index, applied index, apply lag, and member state. &lt;code&gt;MISMATCH&lt;/code&gt;, &lt;code&gt;UNREADABLE&lt;/code&gt;, or &lt;code&gt;MISSING&lt;/code&gt; durable state makes it exit with code &lt;code&gt;1&lt;/code&gt;. A never-activated directory can exit successfully: code &lt;code&gt;0&lt;/code&gt; does not prove a working cluster.&lt;/p&gt;

&lt;p&gt;Use it to investigate what a node would start with. Use readiness details, metrics, client operations, and failure tests to investigate what the running cluster can do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the RF=3 example
&lt;/h2&gt;

&lt;p&gt;The source Compose example includes three nodes, named data volumes, per-node settings, persistence, mTLS, and both failover switches. Start with a fresh checkout of the release tag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone &lt;span class="nt"&gt;--branch&lt;/span&gt; v0.1.0-preview.9 &lt;span class="nt"&gt;--depth&lt;/span&gt; 1 https://github.com/squirix/squirix.git squirix-preview9-demo
&lt;span class="nb"&gt;cd &lt;/span&gt;squirix-preview9-demo/docker
docker compose up &lt;span class="nt"&gt;--build&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;
docker compose ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a local development demo. Its JWT keys and mTLS certificates are public test fixtures, and its HTTPS certificate is for development. Replace that material before adapting the layout to another environment.&lt;/p&gt;

&lt;p&gt;Probe the primary listener from the host:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-k&lt;/span&gt; https://localhost:5001/health/ready
curl &lt;span class="nt"&gt;-k&lt;/span&gt; &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer &amp;lt;jwt&amp;gt;"&lt;/span&gt; https://localhost:5001/health/ready/details
curl &lt;span class="nt"&gt;-k&lt;/span&gt; &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer &amp;lt;jwt&amp;gt;"&lt;/span&gt; https://localhost:5001/metrics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use a JWT matching the Compose issuer, audience, and signing key. The three basic health routes are anonymous; remote metrics and readiness details require authentication. Host-to-container traffic through a published port counts as remote. The &lt;code&gt;-k&lt;/code&gt; flag is only for this development certificate.&lt;/p&gt;

&lt;p&gt;Connect a client with multiple bootstrap endpoints and keep reading and writing a known key. Before stopping anything, identify its replica group and current leader. Record that leader and confirm its authority. If the selected group's leader is node A, the failure sequence is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose &lt;span class="nb"&gt;kill &lt;/span&gt;node-a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Through surviving endpoints, verify that the same key's group acquires a new leader and resumes reads and writes. Read the value acknowledged before the failure, then write and read a new value. A transient refusal during the election is expected; permanent unavailability is not the result this scenario is meant to demonstrate.&lt;/p&gt;

&lt;p&gt;Bring the stopped node back without removing its volume:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose start node-a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Watch its catch-up and check that the acknowledged values remain available. It returns as a follower of that group; restarting the original owner does not restore its leadership. If node B or C leads the selected group, substitute that service in both commands.&lt;/p&gt;

&lt;p&gt;The key detail is the relationship between the key and the stopped node. Killing an arbitrary node can leave the key's leader alive and demonstrate only follower loss. That was the mistake in the earlier test. This walkthrough describes what to verify; the shell commands alone do not establish that failover worked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the retry contract intact
&lt;/h2&gt;

&lt;p&gt;Multiple bootstrap endpoints help a client reach a surviving node. They do not replace a majority, and they do not make an interrupted mutation's result obvious.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CommitOutcomeUnknownException&lt;/code&gt; means the durable outcome is ambiguous. The operation may have committed. Retry under the same &lt;code&gt;operation_id&lt;/code&gt;, within the supported retry window, rather than inventing a new identity and risking a second mutation. Loss of an acknowledgement is not proof that no write happened.&lt;/p&gt;

&lt;p&gt;RF=2 remains a synchronous mirror: both members are needed for writes, and losing either does not trigger promotion. RF=3 with failover enabled can continue on two surviving members after an election, provided they can communicate and retain the required durable state. Losing a majority's disks is outside that guarantee.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this preview leaves to the operator
&lt;/h2&gt;

&lt;p&gt;Membership is static. There is no dynamic membership, automatic rebalancing, or general rolling-upgrade promise. Quotas remain per node. Replication adds network and durable-write latency; quorum reads add their own confirmation round. Backups, capacity planning, and recovery exercises remain necessary.&lt;/p&gt;

&lt;p&gt;The series has now asked three questions: do enough nodes hold a write, who may speak for the group, and can the operator deliberately enable and observe it? The last one is where protocol guarantees become something you can check: the settings agree, the data directory matches, the leader has authority, a majority is ready, and the failure exercise stops the node that actually leads the key under test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;p&gt;In this series:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/from-one-owner-to-a-replica-set-synchronous-replication-in-squirix-preview8-3jmd"&gt;Part 1: From one owner to a replica set&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/who-is-the-leader-elections-fencing-and-why-rf2-cant-fail-over-in-squirix-preview9-2dkn"&gt;Part 2: Who is the leader?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/-the-failover-test-that-stopped-the-wrong-node-4ej2"&gt;The failover test that stopped the wrong node&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Release-specific references:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix" rel="noopener noreferrer"&gt;Squirix on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/releases/tag/v0.1.0-preview.9" rel="noopener noreferrer"&gt;Release v0.1.0-preview.9&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.9/docs/configuration.md" rel="noopener noreferrer"&gt;Configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.9/docs/containerization.md" rel="noopener noreferrer"&gt;Containerization and Compose&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.9/docs/diagnostics.md" rel="noopener noreferrer"&gt;Diagnostics and metrics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.9/docs/operational-runbook.md" rel="noopener noreferrer"&gt;Operational runbook&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.9/docs/architecture/replication-consensus.md" rel="noopener noreferrer"&gt;Replication consensus ADR&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the standalone CLI used above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet tool &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--global&lt;/span&gt; squirix.server.tool &lt;span class="nt"&gt;--version&lt;/span&gt; 0.1.0-preview.9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>dotnet</category>
      <category>distributedsystems</category>
      <category>csharp</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Who is the leader? Elections, fencing, and why RF=2 can't fail over in Squirix preview.9</title>
      <dc:creator>Alex E</dc:creator>
      <pubDate>Tue, 27 Oct 2026 08:23:34 +0000</pubDate>
      <link>https://dev.to/alexander-efremov/who-is-the-leader-elections-fencing-and-why-rf2-cant-fail-over-in-squirix-preview9-2dkn</link>
      <guid>https://dev.to/alexander-efremov/who-is-the-leader-elections-fencing-and-why-rf2-cant-fail-over-in-squirix-preview9-2dkn</guid>
      <description>&lt;p&gt;A month ago I wrote &lt;a href="https://dev.to/alexander-efremov/-the-failover-test-that-stopped-the-wrong-node-4ej2"&gt;a post-mortem&lt;/a&gt; about a failover test that stopped the wrong node:&lt;br&gt;
preview.8 shipped election code that nothing in the server called. I ended it with a promise. The article about elections would wait until elections actually run.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;0.1.0-preview.9&lt;/code&gt; they run. Stop the leader of an RF=3 group and the other two elect a new one, the client keeps working, and the leader-stop tests kill the node that matters.&lt;br&gt;
This is that article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/alexander-efremov/from-one-owner-to-a-replica-set-synchronous-replication-in-squirix-preview8-3jmd"&gt;Part 1&lt;/a&gt; covered the replicated write path: synchronous&lt;br&gt;
mutations, majority commit, write-ahead idempotency intent, and the honest &lt;code&gt;CommitOutcomeUnknown&lt;/code&gt; answer when the owner dies mid-commit. All of that assumes something it never&lt;br&gt;
proves: that a node may serve current reads and acknowledge writes only under the group's quorum-backed authority.&lt;/p&gt;

&lt;p&gt;Without that guarantee, two survivors of a partition can both believe they lead, accept different writes for the same key, and return success for histories that can never be&lt;br&gt;
reconciled. Preventing that requires majority intersection, durable voting and log-freshness rules, plus current-term authority checks on reads and writes.&lt;/p&gt;

&lt;p&gt;Squirix is still an experimental preview, not a production-ready cache. Its APIs, wire format, and storage formats may change during &lt;code&gt;0.x&lt;/code&gt;. This article describes the current&lt;br&gt;
design, not a compatibility promise.&lt;/p&gt;
&lt;h2&gt;
  
  
  Opt-in, and only for three or more
&lt;/h2&gt;

&lt;p&gt;Automatic failover is off by default. Two settings under &lt;code&gt;Squirix:Cluster&lt;/code&gt; turn it on, and they come together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Squirix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Cluster"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"ReplicaCount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"PersistenceEnabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"ReplicationEnabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"AutomaticFailoverEnabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"QuorumReadsEnabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Validation refuses one without the other, and refuses both for groups of one or two replicas. Every node needs the same values, and they are set on empty data directories: the&lt;br&gt;
switches are part of the topology fingerprint. This is a settings fragment: node identity, peers, and inter-node mTLS are also required.&lt;/p&gt;

&lt;p&gt;With failover off, nothing changes from preview.8: the owner of each key leads its group in term one, reads are local, and losing the owner makes its keys &lt;code&gt;Unavailable&lt;/code&gt; until it&lt;br&gt;
comes back. Everything below is about the switched-on mode.&lt;/p&gt;
&lt;h2&gt;
  
  
  The failure mode to avoid
&lt;/h2&gt;

&lt;p&gt;Imagine five nodes split 3–2 by a network cut. The minority side bumps its own term number and declares itself leader. It accepts a write for key K. Meanwhile the majority side&lt;br&gt;
elects a real leader and accepts a different write for K. The partition heals. Which write won? Both clients got success, and the log has a fork nothing can merge.&lt;/p&gt;

&lt;p&gt;The contract that prevents it borrows the oldest Raft lesson:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;no node leads on its own authority
                |
                v
a candidate wins only with a majority of the configured static membership
                |
                v
votes come only from members whose log can vote, but that never shrinks the quorum
                |
                v
a leader that stops hearing from a majority steps down
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A lone node can inflate any number it likes. Without a majority behind it, the number means nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  When an election starts
&lt;/h2&gt;

&lt;p&gt;A follower campaigns when it has heard neither from a leader nor granted a vote for one election timeout: one second plus up to one second of seeded jitter. The leader sends a&lt;br&gt;
heartbeat to every idle follower every 100 ms, so a reachable leader keeps its followers quiet. The first surviving member whose timer expires can start a campaign;&lt;br&gt;
winning still requires a majority, durable votes, and a current-term commit. Timer settings alone do not establish an end-to-end failover latency.&lt;/p&gt;

&lt;p&gt;A campaign starts with a pre-vote for the next term, which changes no term anywhere. A member refuses it with &lt;code&gt;leader-contact&lt;/code&gt; if it heard from a live leader within the last&lt;br&gt;
election timeout. That one rule matters more than it looks: a node cut off from the leader alone would otherwise keep raising the term and depose a perfectly healthy leader every&lt;br&gt;
time it reconnects. With the rule, it campaigns in vain until it can hear the leader again.&lt;/p&gt;

&lt;p&gt;Only with a majority of pre-votes does the candidate persist the new term and its own vote, then ask for real votes. Each vote request has a 250 ms timeout, and a round ends as&lt;br&gt;
soon as its outcome is decided, canceling and awaiting unanswered calls. A silent member therefore need not consume its full vote timeout after a majority has already answered.&lt;/p&gt;

&lt;p&gt;Term one always belongs to the owner of a group, which leads it without votes after the group's first start. The first election is for term two.&lt;/p&gt;
&lt;h2&gt;
  
  
  Terms that survive the process
&lt;/h2&gt;

&lt;p&gt;Every replica group stores a durable &lt;code&gt;current_term&lt;/code&gt; and at most one &lt;code&gt;voted_for&lt;/code&gt; per term in a two-slot metadata file. Term advances and votes are mirrored, but the vote reply waits&lt;br&gt;
only for the first copy to become durable. The same work item then writes the second copy; the next metadata publish and shutdown wait for that pending mirror.&lt;br&gt;
Recovery selects the newest valid slot. A process restart after a granted vote therefore remembers that vote; the reply does not imply both slots were already flushed.&lt;/p&gt;

&lt;p&gt;Voting adds a second gate: log freshness. The voter compares the candidate's last log term, then its last log index, with its own, and refuses a stale candidate with &lt;code&gt;stale-log&lt;/code&gt;. A&lt;br&gt;
new leader that never saw a committed entry cannot win, so it cannot overwrite that entry — the classic "elected but amnesiac" failure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;candidate (lastTerm=4, lastIndex=120) --&amp;gt; voter (lastTerm=5, ...)
                                          |
                                          +--&amp;gt; refuse: stale-log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some members cannot vote at all. A copy that came back on an empty disk is &lt;em&gt;unseeded&lt;/em&gt;: it grants no vote and takes no entries until the group repairs it. A copy whose log is not&lt;br&gt;
ready refuses every ballot. A copy waiting for a state transfer still votes, because its log is real, but it can never stand for election.&lt;/p&gt;
&lt;h2&gt;
  
  
  Authority must be earned, then kept
&lt;/h2&gt;

&lt;p&gt;Winning an election is a moment. Serving traffic is a stream.&lt;/p&gt;

&lt;p&gt;A winner does not serve anything yet. It first appends a &lt;code&gt;leader-noop&lt;/code&gt; record in its own term and waits until a majority commits it. Until then every write is refused before&lt;br&gt;
anything is appended, with &lt;code&gt;Unavailable&lt;/code&gt; and "nothing was read or written". Only that current-term commit lets the leader treat older entries as committed. This is Raft's&lt;br&gt;
leader-completeness rule stated as a startup step, and it closes the window where a new leader serves history it does not yet own.&lt;/p&gt;

&lt;p&gt;Keeping authority is the other half. A leader steps down once fewer than a majority, itself included, answered within one election timeout, and at once when any reply carries a&lt;br&gt;
higher term. A deposed leader's messages carry a stale term, and followers refuse them with &lt;code&gt;stale-term&lt;/code&gt; instead of merging them.&lt;/p&gt;

&lt;p&gt;Some leaders are alive but unable to serve. The initial authority deadline is 30 seconds; repeated failures to obtain authority double that window, up to 240 seconds, and recent&lt;br&gt;
state-transfer progress holds the deadline. A 30-second apply timeout applies while committed work remains unapplied without progress. A local append failure or stall has a&lt;br&gt;
separate 30-second window and causes step-down only while the other electable followers can form a majority with recent contact. These are conditional progress checks, not a&lt;br&gt;
universal 30-second failover guarantee. On shutdown, the election driver revokes local authority; surviving members still acquire leadership through the election protocol.&lt;/p&gt;
&lt;h2&gt;
  
  
  Reads that refuse to guess
&lt;/h2&gt;

&lt;p&gt;With quorum reads on, a read on the leader goes through five steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. check authority in the current term
2. read_index = commit_index
3. confirm with a majority in that term (requests sent after step 2)
4. wait until applied_index &amp;gt;= read_index
5. recheck authority in that term, then return the value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A minority side or a former leader cannot pass step 1 or step 3. It answers &lt;code&gt;Unavailable&lt;/code&gt; (&lt;code&gt;read_quorum_unconfirmed&lt;/code&gt;, &lt;code&gt;read_index_unapplied&lt;/code&gt;) or a stale-term refusal — never an old&lt;br&gt;
value presented as current. There are no time-based lease reads: authority without a quorum is never enough, even when clocks agree.&lt;/p&gt;
&lt;h2&gt;
  
  
  Finding the leader
&lt;/h2&gt;

&lt;p&gt;A client should not have to know who leads. Any node accepts a single-key call, including a node outside the key's group, and forwards it to the leader it knows. If the answer is&lt;br&gt;
&lt;code&gt;stale-owner&lt;/code&gt; or &lt;code&gt;stale-term&lt;/code&gt;, it reroutes once to the leader the answer names. All the leader waits of one call share a three-second attempt budget, and the client's retries share&lt;br&gt;
one 15-second deadline in the default SDK policy. A no-leader refusal before admission means nothing was written by that attempt.&lt;br&gt;
An interrupted attempt that already appended can instead have an unknown commit outcome: keep the same &lt;code&gt;operation_id&lt;/code&gt; when retrying within the supported retention window.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client --&amp;gt; any node --&amp;gt; leader it knows (term 7, current is 9)
                           |
                           +--&amp;gt; stale-term: one reroute to the named leader, then fail visibly
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bounded matters. "Try the next node forever" turns every leadership change into a thundering herd from the clients.&lt;/p&gt;

&lt;p&gt;Every replication RPC also carries the term, the topology fingerprint and the configuration generation in its header. A message from another world — wrong group, older&lt;br&gt;
configuration, a node below the minimum cluster version — is refused before it touches the log.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why RF=2 stays a mirror
&lt;/h2&gt;

&lt;p&gt;The same majority rule that saves RF&amp;gt;=3 condemns RF=2 to honesty.&lt;/p&gt;

&lt;p&gt;With two members the majority is two. Lose either node and the survivor holds one vote out of two. It cannot elect itself, cannot commit, cannot promote. That is not a missing&lt;br&gt;
feature; it is the protocol refusing to invent authority it does not have. Validation does not even let you switch failover on for RF=2.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RF=2, both alive:   synchronous mirror, every write on both nodes
RF=2, follower lost: writes stop; the surviving owner can still serve local reads
RF=2, owner lost:    its keys are unavailable; the surviving follower never promotes
RF&amp;gt;=3, one lost:     with failover on, a surviving majority can elect and keep serving
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two-node majority systems that promote on peer loss are single-node systems with extra steps — and extra data loss.&lt;/p&gt;

&lt;h2&gt;
  
  
  Coming back
&lt;/h2&gt;

&lt;p&gt;A node that returns after an outage catches up from the leader's log. If the leader's log no longer holds what it needs — it was compacted, or the node came back on an empty disk —&lt;br&gt;
the leader sends a state transfer: group snapshot metadata and idempotency outcomes plus the group's cache entries. The group snapshot alone is not a full cache image.&lt;br&gt;
A wiped copy also forgot whom it voted for, so the leader checks a term ceiling with a majority that includes itself and excludes the wiped member before repairing it.&lt;br&gt;
The required peer answers come from members that retained their durable term, preventing the forgotten vote from silently creating authority.&lt;/p&gt;

&lt;p&gt;A returning node does not take the group back. It stays a follower: its peers refuse its pre-vote while they hear the current leader, and nobody votes for a stale log. Membership&lt;br&gt;
is not readiness to lead.&lt;/p&gt;
&lt;h2&gt;
  
  
  A model that is allowed to say no
&lt;/h2&gt;

&lt;p&gt;Before any election code landed, I froze the protocol in an ADR with an executable C# model (&lt;code&gt;src/squirix.protocol-model&lt;/code&gt;, never shipped, never referenced by product code). It has&lt;br&gt;
immutable state, pure transitions, a deterministic BFS explorer, and invariants that report minimal counterexample traces.&lt;/p&gt;

&lt;p&gt;The explorer covers elections, commit, and quorum reads for RF=2 through RF=5, with crash points before and after every durable write of term, vote, log, and commit index, and with&lt;br&gt;
loss, duplication, reorder, and one-way isolation of a node. Newer profiles add disk loss and repair. A profile that hits its state cap without a violation exits differently from a&lt;br&gt;
clean fixed point, so residual risk stays visible instead of silently passing.&lt;/p&gt;

&lt;p&gt;Just as important are the broken variants that must produce counterexamples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;grant a second vote in the same term;&lt;/li&gt;
&lt;li&gt;compare log length before the last term when voting;&lt;/li&gt;
&lt;li&gt;commit an old-term entry without a current-term commit;&lt;/li&gt;
&lt;li&gt;serve a read without a majority confirm, or before apply catches up;&lt;/li&gt;
&lt;li&gt;repair a wiped copy without the term ceiling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the explorer ever stops finding those violations, the harness is broken, not the protocol sound. Conformance tests run real product components and ask the model whether it can&lt;br&gt;
reach the same trace.&lt;/p&gt;

&lt;p&gt;The post-mortem was about the gap between this model and the server. The model checks invariants within its explored bounds; it never said the server runs it.&lt;br&gt;
What closes the gap now are the E2E tests: an RF=3 and an RF=5 cluster whose leader is stopped, a leader isolated by a partition, and a five-node 2/3 split with the leader in the&lt;br&gt;
minority. Other scenarios repair a wiped follower by state transfer and restart a former leader that stays a follower. The tests that stop a node assert that it was the leader.&lt;/p&gt;
&lt;h2&gt;
  
  
  What preview.9 does not promise
&lt;/h2&gt;

&lt;p&gt;Membership is static: no dynamic membership, rebalancing, or joint consensus. Election timings are fixed per member; the group's detection still shortens with more replicas. The&lt;br&gt;
model covers single-node isolation; the five-node split is covered by a test, not by the model, and richer partitions remain residual risk. A group that lost the disks of a&lt;br&gt;
majority of its members at once is not repaired.&lt;/p&gt;
&lt;h2&gt;
  
  
  Closing thought
&lt;/h2&gt;

&lt;p&gt;Commit protocols ask: do enough nodes hold this write? Election protocols ask the harder question first: who is allowed to ask?&lt;/p&gt;

&lt;p&gt;The hard part is refusing authority precisely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;no majority, no leadership — even if the node feels healthy;&lt;/li&gt;
&lt;li&gt;stale log, no votes — even with supporters;&lt;/li&gt;
&lt;li&gt;no current-term commit, no serving old history;&lt;/li&gt;
&lt;li&gt;no quorum confirm, no current read;&lt;/li&gt;
&lt;li&gt;a live leader, no pre-vote for anyone else.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Preview.9 makes each refusal durable, fenced, and observable — and, this time, switched on. &lt;a href="https://dev.to/alexander-efremov/operating-a-replica-set-opt-in-metrics-and-an-rf3-docker-demo-in-squirix-preview9-4p19"&gt;Part 3&lt;/a&gt; covers what operators see: the opt-in, metrics, readiness, and an RF=3 compose example you can run.&lt;/p&gt;

&lt;p&gt;If you build leader election or quorum reads in .NET, comments are welcome on where you draw the same lines — especially vote persistence, pre-vote, and rerouting budgets.&lt;/p&gt;
&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;p&gt;Squirix docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/releases/tag/v0.1.0-preview.9" rel="noopener noreferrer"&gt;Release &lt;code&gt;v0.1.0-preview.9&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.9/docs/architecture/replication-consensus.md" rel="noopener noreferrer"&gt;Replication consensus ADR&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.9/docs/clustering.md" rel="noopener noreferrer"&gt;Clustering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.9/docs/configuration.md#automatic-failover-and-quorum-reads" rel="noopener noreferrer"&gt;Configuration (automatic failover)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.9/docs/consistency.md" rel="noopener noreferrer"&gt;Consistency&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this series:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/from-one-owner-to-a-replica-set-synchronous-replication-in-squirix-preview8-3jmd"&gt;Part 1, from one owner to a replica set&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/-the-failover-test-that-stopped-the-wrong-node-4ej2"&gt;The failover test that stopped the wrong node&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/operating-a-replica-set-opt-in-metrics-and-an-rf3-docker-demo-in-squirix-preview9-4p19"&gt;Part 3, operating a replica set&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package squirix &lt;span class="nt"&gt;--version&lt;/span&gt; 0.1.0-preview.9
dotnet add package squirix.server &lt;span class="nt"&gt;--version&lt;/span&gt; 0.1.0-preview.9
dotnet tool &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--global&lt;/span&gt; squirix.server.tool &lt;span class="nt"&gt;--version&lt;/span&gt; 0.1.0-preview.9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>dotnet</category>
      <category>distributedsystems</category>
      <category>csharp</category>
      <category>opensource</category>
    </item>
    <item>
      <title># The failover test that stopped the wrong node</title>
      <dc:creator>Alex E</dc:creator>
      <pubDate>Wed, 30 Sep 2026 07:33:32 +0000</pubDate>
      <link>https://dev.to/alexander-efremov/-the-failover-test-that-stopped-the-wrong-node-4ej2</link>
      <guid>https://dev.to/alexander-efremov/-the-failover-test-that-stopped-the-wrong-node-4ej2</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Update, October 27, 2026.&lt;/strong&gt; &lt;code&gt;0.1.0-preview.9&lt;/code&gt; wires automatic failover for RF&amp;gt;=3, opt-in. &lt;a href="https://dev.to/alexander-efremov/who-is-the-leader-elections-fencing-and-why-rf2-cant-fail-over-in-squirix-preview9-2dkn"&gt;Part 2&lt;/a&gt; explains how elections and fencing work now.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Two weeks ago I shipped Squirix &lt;code&gt;0.1.0-preview.8&lt;/code&gt;. The release notes said RF&amp;gt;=3 clusters survive the loss of a node: the majority elects a new leader, stale leaders get fenced, clients get rerouted. Then I published &lt;a href="https://dev.to/alexander-efremov/from-one-owner-to-a-replica-set-synchronous-replication-in-squirix-preview8-3jmd"&gt;the first article of a series&lt;/a&gt; about how it works.&lt;/p&gt;

&lt;p&gt;On September 23 I found out that the failover part doesn't run in the shipped server. The code exists. It has unit tests, an executable model, E2E tests, and green CI. Nothing in the production host calls it.&lt;/p&gt;

&lt;p&gt;I've added an update to part 1. This post is the longer version: how a feature can be written, tested, and documented without ever being switched on, and what I'm changing so it doesn't happen again. The article about elections waits until elections actually run.&lt;/p&gt;

&lt;h2&gt;
  
  
  An analyzer I had told to be quiet
&lt;/h2&gt;

&lt;p&gt;It started with warnings I had silenced myself.&lt;/p&gt;

&lt;p&gt;Squirix builds with Meziantou.Analyzer, and its rule MA0182 flags internal types that nothing references. In the replication code there were seven suppressions of it, all with nearly the same justification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;SuppressMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"Usage"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"MA0182:Internal type is apparently never used"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Justification&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Test-only activation seam until failover activation wires the gate in a follow-up milestone."&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;internal&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FailoverActivationGate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The seven types were the election timer, the failover activation gate, the leader read barrier, the snapshot catch-up session, the reroute budget, the stale-term classifier, and the election commit rule. That is most of failover.&lt;/p&gt;

&lt;p&gt;"Follow-up milestone" sounds like a plan, so I went looking for it. There wasn't one. The milestone folder had preview.8 itself and a backlog with one unrelated item. &lt;code&gt;git log -S&lt;/code&gt; showed the suppressions were added inside the preview.8 pull requests, around September 6 and 7. The follow-up only ever existed in the justification string.&lt;/p&gt;

&lt;p&gt;The analyzer was right the whole time. It said "nobody uses this", and nobody did.&lt;/p&gt;

&lt;h2&gt;
  
  
  What was actually missing
&lt;/h2&gt;

&lt;p&gt;Once I stopped trusting the closed issues and read the host wiring instead, the list grew quickly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;AutomaticFailoverEnabled&lt;/code&gt; and &lt;code&gt;QuorumReadsEnabled&lt;/code&gt; existed on the internal topology options. Nothing in &lt;code&gt;src/&lt;/code&gt; read them. Only tests set them to &lt;code&gt;true&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The replication gRPC contract had no PreVote or RequestVote RPC. Nodes had no way to ask each other for a vote over the network. The vote handling in the follower log was called only from tests.&lt;/li&gt;
&lt;li&gt;The repair service was registered and running, but nothing ever queued work for it.&lt;/li&gt;
&lt;li&gt;The request path had no reroute or stale-term handling, although the release notes promised "bounded client rerouting on stale terms".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every issue in the failover part of the milestone was closed. The exit gate checklist at the bottom of the milestone plan, the one that says to enable failover in production after the proof matrix passes, had no boxes ticked. I didn't read it before tagging.&lt;/p&gt;

&lt;p&gt;Some of it did ship and run: the replication opt-in with its persistence and mTLS checks, the replica ring and topology fingerprint, the replication contract, durable follower logs, and the majority-commit write path. But lose the owner of a key and the key is unavailable until the owner comes back, same as in preview.7.&lt;/p&gt;

&lt;h2&gt;
  
  
  The test that stopped the wrong node
&lt;/h2&gt;

&lt;p&gt;This part bothers me most, because it existed to catch exactly this.&lt;/p&gt;

&lt;p&gt;The milestone had a hard requirement: stop the leader of an RF=3 group, and the remaining majority serves reads and writes within five seconds. There was a test for it, and it was green. Here is its shape at the preview.8 tag, trimmed a little:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;KeyOwnerHelper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ThreeNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FindKeyOwnedBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"nodeB"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"failover-recover"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;var&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;LoopbackConnect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConnectAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uriB&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;uriC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetCacheAsync&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"before-loss"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cluster&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;StopNodeAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"nodeA"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"after-loss"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;Assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"after-loss"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetValueAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Token&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key is owned by nodeB. The test stops nodeA. With three nodes and RF=3, nodeA is just a follower for this key. The owner stays up, nodeB and nodeC still make a majority, the write commits, and the read returns it. No election is needed, none happens, and the test passes well inside five seconds.&lt;/p&gt;

&lt;p&gt;The release test suite had a second test with the same bug. Two separate proofs of failover, and both killed a follower.&lt;/p&gt;

&lt;p&gt;I can see how it happened. &lt;code&gt;FindKeyOwnedBy("nodeB")&lt;/code&gt; and &lt;code&gt;StopNodeAsync("nodeA")&lt;/code&gt; sit a few lines apart, each looks reasonable on its own, and the assertion at the end checks the outcome you care about. What the test never checks is that the node it destroyed was the one that mattered. A failure test that doesn't assert what it killed can pass for the wrong reason indefinitely.&lt;/p&gt;

&lt;h2&gt;
  
  
  The model was fine
&lt;/h2&gt;

&lt;p&gt;The strange part is that the hard thinking had been done. Before writing election code I froze the protocol in an ADR with an executable C# model: a BFS explorer over elections, commits, and quorum reads for RF=2 to RF=5, with crashes around every durable write and deliberately broken variants that must produce counterexamples.&lt;/p&gt;

&lt;p&gt;That model says the protocol is safe. It says nothing about whether the server runs the protocol. I had solid evidence about one thing and was reading it as evidence about another.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'm changing
&lt;/h2&gt;

&lt;p&gt;The fixes are small, which is probably why they were missing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Failure tests assert what they kill. The leader-stop tests now pick a key owned by the node they stop. Until failover is wired, they are skipped with an explicit reason: "Automatic failover is not yet wired into production". A skipped test with a reason tells the truth. A green test that exercises nothing doesn't.&lt;/li&gt;
&lt;li&gt;"Later" needs an address. A suppression or TODO that defers work to a follow-up has to name a tracked issue. If it can't, the work isn't deferred, it's dropped.&lt;/li&gt;
&lt;li&gt;Release notes come from the code, not from the tracker. Each claim should point at a test or a code path in the shipped host.&lt;/li&gt;
&lt;li&gt;Closed issues don't make a milestone done. The exit gate gets read, and ticked, before the tag.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where failover stands
&lt;/h2&gt;

&lt;p&gt;Wiring it up is now tracked as its own piece of work, split into eleven units: storage support for elections, the vote RPCs, the election driver, the follower apply loop, repair, routing and authority checks on the request path, the public switches, and a real E2E proof matrix in which the leader actually dies.&lt;/p&gt;

&lt;p&gt;The audit also turned up two problems that had to be fixed first. A leader that restarted with an uncommitted log tail could never commit again. And on a slow disk, a client timeout could cancel a commit after its decision point. Both are fixed on the development branch now.&lt;/p&gt;

&lt;p&gt;When the leader-stop tests are un-skipped and pass for real, I'll pick the series back up with elections, fencing, and why RF=2 never promotes. That article is already written. It just has to become true first.&lt;/p&gt;

&lt;p&gt;If you've had a green test that was lying to you, I'd like to hear how you caught it. Mine was caught by an analyzer I had told to be quiet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/from-one-owner-to-a-replica-set-synchronous-replication-in-squirix-preview8-3jmd"&gt;Part 1, with the update&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/issues/646" rel="noopener noreferrer"&gt;The audit issue&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/issues/650" rel="noopener noreferrer"&gt;Failover wiring tracker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dotnet</category>
      <category>distributedsystems</category>
      <category>csharp</category>
      <category>testing</category>
    </item>
    <item>
      <title>From one owner to a replica set: synchronous replication in Squirix preview.8</title>
      <dc:creator>Alex E</dc:creator>
      <pubDate>Tue, 15 Sep 2026 06:56:02 +0000</pubDate>
      <link>https://dev.to/alexander-efremov/from-one-owner-to-a-replica-set-synchronous-replication-in-squirix-preview8-3jmd</link>
      <guid>https://dev.to/alexander-efremov/from-one-owner-to-a-replica-set-synchronous-replication-in-squirix-preview8-3jmd</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Update, October 27, 2026.&lt;/strong&gt; &lt;code&gt;0.1.0-preview.9&lt;/code&gt; wires what this release lacked: opt-in automatic&lt;br&gt;
failover for RF&amp;gt;=3, followers that apply entries and can serve, and repair by catch-up or state transfer.&lt;br&gt;
&lt;a href="https://dev.to/alexander-efremov/who-is-the-leader-elections-fencing-and-why-rf2-cant-fail-over-in-squirix-preview9-2dkn"&gt;Part 2&lt;/a&gt;&lt;br&gt;
covers elections, fencing, and why RF=2 cannot fail over. &lt;a href="https://dev.to/alexander-efremov/operating-a-replica-set-opt-in-metrics-and-an-rf3-docker-demo-in-squirix-preview9-4p19"&gt;Part 3&lt;/a&gt; covers operating and observing a replica set.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update, September 30, 2026.&lt;/strong&gt; After publishing this article I found that replication in the&lt;br&gt;
&lt;code&gt;0.1.0-preview.8&lt;/code&gt; packages is only partly active, and this article overstates it.&lt;/p&gt;

&lt;p&gt;What ships: the explicit &lt;code&gt;ReplicationEnabled&lt;/code&gt; opt-in, the replica ring and topology fingerprint, the&lt;br&gt;
server-only replication contract over mTLS, durable follower logs, and the majority-commit write path.&lt;/p&gt;

&lt;p&gt;What does not: leader election and automatic failover exist only behind internal switches that are&lt;br&gt;
off by default, with no public setting to turn them on. Followers persist entries but do not apply&lt;br&gt;
them to memory, so they cannot serve the key. Snapshot-based catch-up is not wired in production.&lt;/p&gt;

&lt;p&gt;In practice, if the owner node is lost in preview.8, its keys stay unavailable until it comes back,&lt;br&gt;
just as in preview.7. The "RF&amp;gt;=3 survives single-node loss" claim below does not hold for this&lt;br&gt;
release. Read the rest as the design we are building toward, not as shipped behavior.&lt;br&gt;
The remaining wiring is tracked in &lt;a href="https://github.com/squirix/squirix/issues/650" rel="noopener noreferrer"&gt;the failover wiring issue&lt;/a&gt;.&lt;br&gt;
That was the publication status on September 30; the October 27 update above supersedes it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;a href="https://dev.to/alexander-efremov/when-the-disk-fills-up-pressure-and-tenant-isolation-in-squirix-preview7-3dpa"&gt;preview.7 article&lt;/a&gt; covered what happens when a node&lt;br&gt;
should stop accepting durable work: journal disk quotas with &lt;code&gt;JOURNAL_DISK_QUOTA&lt;/code&gt;, and per-principal backpressure keyed by JWT subject. That work made overload explicit on one&lt;br&gt;
node.&lt;/p&gt;

&lt;p&gt;It does not answer the next uncomfortable question: what happens when the node that owns your key is gone?&lt;/p&gt;

&lt;p&gt;Up to preview.7, Squirix durability was per node. A pipelined binary WAL, group commit, snapshot recovery, and durable idempotency outcomes (preview.6) survive a process crash —&lt;br&gt;
but only if the same disk comes back. Lose the owner and the key is unavailable until that node returns. No other node can serve it, because no other node has it.&lt;/p&gt;

&lt;p&gt;That question shaped &lt;code&gt;0.1.0-preview.8&lt;/code&gt;: replica sets with synchronous replicated mutations and majority commit. RF=1 keeps the old single-owner behavior. The goal: RF&amp;gt;=3 survives&lt;br&gt;
single-node loss on the remaining majority.&lt;/p&gt;

&lt;p&gt;Squirix is still an experimental preview, not a production-ready cache. Its APIs, wire format, and storage formats may change during &lt;code&gt;0.x&lt;/code&gt;. This article describes the current&lt;br&gt;
design and the reasoning behind it, not a compatibility promise.&lt;/p&gt;
&lt;h2&gt;
  
  
  The failure mode to avoid
&lt;/h2&gt;

&lt;p&gt;Imagine a three-node cluster holding a hot key on node A. Node A loses power. The journal on A is intact, but A is unreachable. Clients keep retrying the bootstrap endpoints, and&lt;br&gt;
every retry routes to the same answer: the owner is down, the data is on its disk, nobody else may serve it.&lt;/p&gt;

&lt;p&gt;The target contract is boring and explicit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client mutation, operation_id = 4f...
                |
                v
owner appends to its log + replicates to the group
                |
                v
majority durably acknowledges (2 of 3)
                |
                v
owner applies in memory, returns success
                |
                v
owner dies -&amp;gt; remaining majority still holds the committed prefix
                |
                v
a new leader elected by the surviving majority serves the key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No acknowledged replicated write lives on exactly one disk. If the client got success at RF&amp;gt;1, a majority holds it. (RF=1 is the exception that proves the rule: its majority is one&lt;br&gt;
node, so a single disk still holds the only copy.) That is the whole point of making replication synchronous on the mutation path rather than shipping logs in the background and&lt;br&gt;
hoping.&lt;/p&gt;

&lt;p&gt;This is different from the "commit unknown" case in preview.6. There, durable bytes may exist on one node while the client saw only a timeout. Here, the ambiguity spans nodes: the&lt;br&gt;
owner may have replicated far enough that the outcome survives its own death. Clients need a stable answer for that case too, which is where the new &lt;code&gt;CommitOutcomeUnknown&lt;/code&gt; contract&lt;br&gt;
comes in (more below).&lt;/p&gt;
&lt;h2&gt;
  
  
  From single owner to replica set
&lt;/h2&gt;

&lt;p&gt;The Squirix server already routes each key to one owner with static consistent-hash routing. Preview.8 does not replace that. It widens that ownership into a replica group.&lt;/p&gt;

&lt;p&gt;The pieces landed in dependency order across the preview.8 window:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who replicates what: a physical replica ring and topology fingerprint.&lt;/strong&gt; Key ownership comes from the existing consistent-hash ring, while
replicas are the next RF−1 distinct node IDs on a separate sorted ring. The fingerprint hashes the canonical configuration, so a mismatched peer fails
visibly instead of diverging silently;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One knob, three behaviors: &lt;code&gt;ReplicaCount&lt;/code&gt; activation guards.&lt;/strong&gt; RF=1, RF=2, and RF&amp;gt;=3 get different runtime behavior instead of one blurred mode:

&lt;ul&gt;
&lt;li&gt;RF=1 keeps the previous single-owner path with no replication, elections, or group checks running at all;&lt;/li&gt;
&lt;li&gt;RF=2 is a synchronous mirror whose majority of two stops writes when either member is lost, with no replacement elected;&lt;/li&gt;
&lt;li&gt;RF&amp;gt;=3 can commit without every replica; automatic replacement requires the preview.9 failover opt-in described in part 2;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replication stays server-internal: a separate contract with mTLS identity.&lt;/strong&gt; It lives on the internal listener and is deliberately separate from the
shared &lt;code&gt;SquirixCache.proto&lt;/code&gt;, so cache clients never see replication RPCs;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Followers that can always catch up: an ordered log plus snapshots.&lt;/strong&gt; Every follower append is journal-backed with no memory-only shortcut, and
replica-group snapshots carry idempotency state, so a lagging follower catches up by installation rather than replay alone;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Success means a majority has it: a durable commit pipeline.&lt;/strong&gt; It culminates in synchronous replicated mutations, with RF=1 behavior preserved:
the server returns success only after a majority of the group durably acknowledges, and applies to memory only the committed prefix.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What differs in practice is what losing a member costs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RF=1:  owner only, no replication, no failover
RF=2:  owner + 1 follower, majority = 2, mirror stops on any loss
RF&amp;gt;=3: owner + followers, majority commit; elections require preview.9 and explicit opt-in
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Static membership is a deliberate constraint. Peers are configured explicitly; there is no dynamic rebalancing in this preview. That removes a whole class&lt;br&gt;
of membership races from the first replicated release and lets the safety work focus on election, commit, and leadership change.&lt;/p&gt;
&lt;h2&gt;
  
  
  The write path: majority before success
&lt;/h2&gt;

&lt;p&gt;For a replicated mutation, the ordering rule extends the preview.6 journal-first rule across nodes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Do not return success before a majority of the configured group has durably acknowledged the mutation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The path looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;validate and admit the mutation
            |
            v
reserve a log index in the group
            |
            v
append locally + replicate to followers
            |
            v
wait for durable majority acknowledgements
            |
            v
advance commit_index, apply in memory
            |
            v
return success
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each mutation completes only when covered by that majority-durability step — the same "completed means covered" idea as preview.6 group commit, lifted from one&lt;br&gt;
&lt;code&gt;fsync&lt;/code&gt; to a quorum of them.&lt;/p&gt;

&lt;p&gt;Two details matter in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log-index reservation can be refused when exhausted. That refusal is definitive for the attempt: nothing was appended, nothing was applied. It fails closed before durability,
like memory admission and journal quota in earlier previews.&lt;/li&gt;
&lt;li&gt;Followers validate appends before copying entry payloads and gate tail reads, so a corrupt or out-of-range frame never becomes a committed prefix by accident.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Expiration follows the same pipeline rather than sneaking around it. Expiration candidates get their own operation identity and flow through the commit coordinator,&lt;br&gt;
so an expiration the leader observes becomes a committed entry applied identically on every replica — a follower never expires a key on its own.&lt;/p&gt;
&lt;h2&gt;
  
  
  Write-ahead intent and the honest unknown
&lt;/h2&gt;

&lt;p&gt;Preview.6 already gave every mutation an opaque &lt;code&gt;operation_id&lt;/code&gt; with a request fingerprint, propagated across owner-routing hops so a retry on another entry node still deduplicates&lt;br&gt;
on the key owner.&lt;/p&gt;

&lt;p&gt;Preview.8 reserves the operation identity before running the mutation handler. On the local journal path, the durable mutation frame carries the operation id and acts as the&lt;br&gt;
write-ahead intent; it is not a separate durable intent record acknowledged before the handler starts. Recovery can reconstruct a started operation whose response is missing and&lt;br&gt;
refuse blind re-execution. Knowing that an operation started does not always recover its original response: the result can remain unknown.&lt;/p&gt;

&lt;p&gt;Even so, replication adds a case where the server cannot honestly say "committed" or "rejected." The owner replicated to some followers, crashed before learning whether a majority&lt;br&gt;
persisted the entry, and the client saw a timeout. The outcome may have committed on the survivors.&lt;/p&gt;

&lt;p&gt;That is the new &lt;code&gt;CommitOutcomeUnknown&lt;/code&gt; contract. Mutations can now throw &lt;code&gt;CommitOutcomeUnknownException&lt;/code&gt; when the durable commit outcome is ambiguous. Retrying with the same&lt;br&gt;
&lt;code&gt;operation_id&lt;/code&gt; avoids blind re-execution while its deduplication record is retained. A retained completed outcome can be replayed; an unresolved record can keep reporting unknown.&lt;br&gt;
This is bounded deduplication, not an unlimited exactly-once guarantee. In preview.8 resolved group records expire; preview.9 also permits capacity eviction after a minimum&lt;br&gt;
retention floor. Reuse after the record is gone is not protected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client --operation_id=4f--&amp;gt; owner (crashes mid-commit)
   |
   +--retry, same operation_id--&amp;gt; new leader
                                      |
                                      +--&amp;gt; replay a retained outcome, or report unknown
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is not a distributed transaction, and it is not presented as one. It is the same idempotency idea from preview.6, extended to the window where the owner set changes under&lt;br&gt;
the client.&lt;/p&gt;
&lt;h2&gt;
  
  
  Catch-up: logs first, snapshots when behind
&lt;/h2&gt;

&lt;p&gt;A follower that restarts or falls behind does not get a special path. It gets the same log, from the point it diverged.&lt;/p&gt;

&lt;p&gt;The follower log keeps an ordered, durable prefix with explicit term and index on every entry. Catch-up replays from the follower's last durable index: matching prefix is kept,&lt;br&gt;
conflicting suffix is replaced, missing suffix is appended. The preview.8 snapshot APIs below describe storage primitives, not an active production repair loop.&lt;br&gt;
Preview.9 wires repair and uses state transfer when retained log replay cannot repair the copy, including a copy that lost its disk.&lt;/p&gt;

&lt;p&gt;A group snapshot is an atomic, checksummed file with group identity, topology fingerprint, term/index boundaries, commit index, and retained committed idempotency outcomes.&lt;br&gt;
It does not contain a complete image of the cache's keys and values. Preview.9 state transfer combines that snapshot with the group's cache entries to repair application state.&lt;/p&gt;

&lt;p&gt;A follower installs a snapshot only from its own group, and only when the topology fingerprint matches and the configuration generation is compatible. Anything else is refused&lt;br&gt;
before a single byte is applied.&lt;/p&gt;

&lt;p&gt;Installing replaces the follower's committed prefix. Entries past the snapshot boundary may stay, but only when the follower's entry exactly at the boundary matches the snapshot's&lt;br&gt;
last-included index and term. On any divergence at that boundary, the follower's tail is discarded and replayed fresh from the leader log. Compaction afterwards trims only the journal&lt;br&gt;
prefix the snapshot covers, keeping the log header and the snapshot itself installable.&lt;/p&gt;

&lt;p&gt;Three log-boundary examples follow. They illustrate the retained prefix, not a complete transfer of application state: preview.9 also transfers cache entries when needed.&lt;br&gt;
In each example the leader holds entries 1 through 6, and a primed entry (like &lt;code&gt;3'&lt;/code&gt;) means the same index written in an older term:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;leader:   [1][2][3][4][5][6]

Case 1 — small gap, conflicting tail.
The follower is almost current, but its last entry belongs to an older term:
follower: [1][2][3']           -&amp;gt; drop 3', copy 3..6 from the leader
result:   [1][2][3][4][5][6]

Case 2 — gap larger than the retained log.
The follower is so far behind that replaying entry by entry is no longer possible:
follower: [1]                  -&amp;gt; install the snapshot (state through 5),
                                  then replay entry 6 from the leader
result:   snapshot[1..5] + [6]

Case 3 — the snapshot boundary itself was written in another term.
The follower's tail overlaps the snapshot but disagrees with it at the boundary:
follower: [1][2][3][4][5']     -&amp;gt; install the snapshot (state through 5),
                                  discard the conflicting 5', replay 6
result:   snapshot[1..5] + [6]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The idempotency state rides along on purpose. Transferring values without retained retry identity can let a delayed retry execute twice after old segments are compacted away.&lt;br&gt;
Group snapshots carry committed outcomes so repair preserves deduplication within its retention contract, as well as the transferred cache data.&lt;/p&gt;
&lt;h2&gt;
  
  
  What preview.8 changes
&lt;/h2&gt;

&lt;p&gt;The replication work in &lt;code&gt;0.1.0-preview.8&lt;/code&gt; includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;replica sets RF 1–5 with static membership and a physical replica ring;&lt;/li&gt;
&lt;li&gt;synchronous replicated mutations with durable majority commit; RF=1 behavior preserved;&lt;/li&gt;
&lt;li&gt;operation-id reservation before the handler and write-ahead mutation frames for recovery;&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;CommitOutcomeUnknown&lt;/code&gt; contract for ambiguous durable outcomes;&lt;/li&gt;
&lt;li&gt;ordered follower-log recovery and catch-up/snapshot storage primitives with idempotency state; production repair is connected in preview.9;&lt;/li&gt;
&lt;li&gt;a server-only replication gRPC contract on the internal listener with mTLS identity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of that improves availability. Most of it exists because awkward timing now spans nodes: an owner that dies after replicating halfway, a follower that returns with a&lt;br&gt;
conflicting suffix, a retry that arrives at a new leader. The happy path — three healthy nodes agreeing — is necessary, but the cases above are where the design is decided.&lt;/p&gt;
&lt;h2&gt;
  
  
  What preview.8 does not promise
&lt;/h2&gt;

&lt;p&gt;This work lays the foundation for surviving single-node loss at RF&amp;gt;=3, but Squirix is still early software.&lt;/p&gt;

&lt;p&gt;Replication is synchronous and per key group; multi-key operations are not transactions across owners. RF=2 never promotes after peer loss. Quorum reads and leader election&lt;br&gt;
details will be covered in part 2; the operator surface (opt-in, metrics, RF=3 compose demo) in part 3 — links below.&lt;/p&gt;

&lt;p&gt;The on-disk format may change during &lt;code&gt;0.x&lt;/code&gt;. Synchronous replication is not a substitute for backups or recovery testing. Preview.8 is a stronger foundation for availability, not a&lt;br&gt;
production-readiness claim.&lt;/p&gt;
&lt;h2&gt;
  
  
  Closing thought
&lt;/h2&gt;

&lt;p&gt;Durability work asks: what survives a crash? Replication work asks: what survives the loss of the machine that holds the answer?&lt;/p&gt;

&lt;p&gt;The difficult part is keeping the same honesty when the owner changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;success means a majority holds it, not one disk;&lt;/li&gt;
&lt;li&gt;unknown means unknown, with a stable identity to retry;&lt;/li&gt;
&lt;li&gt;a follower that returns gets the log it missed, or a snapshot that preserves retry identity — never a guess.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Preview.8 makes those boundaries explicit across nodes. The next article goes one level deeper into how the cluster decides who may speak for a group: terms, votes, fencing, and&lt;br&gt;
why RF=2 stays a mirror.&lt;/p&gt;

&lt;p&gt;If you run replicated .NET state or care about quorum commit semantics, comments are welcome on where this model still surprises — especially majority-commit latency,&lt;br&gt;
&lt;code&gt;CommitOutcomeUnknown&lt;/code&gt; handling, and snapshot-vs-log catch-up thresholds.&lt;/p&gt;
&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;p&gt;Squirix docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/releases/tag/v0.1.0-preview.8" rel="noopener noreferrer"&gt;Release &lt;code&gt;v0.1.0-preview.8&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.8/docs/architecture/replication-consensus.md" rel="noopener noreferrer"&gt;Replication consensus ADR (preview.8 design)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.8/docs/clustering.md" rel="noopener noreferrer"&gt;Clustering (preview.8)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/v0.1.0-preview.8/docs/bootstrap-client-failover.md" rel="noopener noreferrer"&gt;Bootstrap client failover (preview.8)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Earlier in this series:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/what-happens-after-a-write-reworking-squirixs-wal-in-preview6-5ha4"&gt;What happens after a write? (preview.6)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/when-the-disk-fills-up-pressure-and-tenant-isolation-in-squirix-preview7-3dpa"&gt;When the disk fills up (preview.7)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next in this series:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/who-is-the-leader-elections-fencing-and-why-rf2-cant-fail-over-in-squirix-preview9-2dkn"&gt;Part 2, who is the leader? Elections, fencing, and why RF=2 can't fail over&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/alexander-efremov/operating-a-replica-set-opt-in-metrics-and-an-rf3-docker-demo-in-squirix-preview9-4p19"&gt;Part 3, operating a replica set&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package squirix &lt;span class="nt"&gt;--version&lt;/span&gt; 0.1.0-preview.8
dotnet add package squirix.server &lt;span class="nt"&gt;--version&lt;/span&gt; 0.1.0-preview.8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>distributedsystems</category>
      <category>opensource</category>
      <category>csharp</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>When the disk fills up: pressure and tenant isolation in Squirix preview.7</title>
      <dc:creator>Alex E</dc:creator>
      <pubDate>Sun, 26 Jul 2026 15:03:06 +0000</pubDate>
      <link>https://dev.to/alexander-efremov/when-the-disk-fills-up-pressure-and-tenant-isolation-in-squirix-preview7-3dpa</link>
      <guid>https://dev.to/alexander-efremov/when-the-disk-fills-up-pressure-and-tenant-isolation-in-squirix-preview7-3dpa</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Update, September 30, 2026.&lt;/strong&gt; An audit after the preview.8 replication problems found that part of this article describes behavior the &lt;code&gt;0.1.0-preview.7&lt;/code&gt; server never applies.&lt;br&gt;
What works: the journal disk quota. A durable write that would exceed the cap is rejected with &lt;code&gt;JOURNAL_DISK_QUOTA&lt;/code&gt;, the process stays up, and &lt;code&gt;/health/ready/details&lt;/code&gt; reports &lt;code&gt;journalDisk&lt;/code&gt; pressure.&lt;br&gt;
Node-wide backpressure (in-flight and queue limits) is active as well.&lt;br&gt;
What does not: per-client isolation. The server resolves a client id for every operation, but the per-client concurrency and rate limits are internal options with no public setting, so they are never switched on. One noisy caller can still use the whole node budget. The quota and the node-wide limits also run at fixed defaults: &lt;code&gt;JournalMaxTotalBytesMb&lt;/code&gt; (2048 MiB) cannot be changed from the shipped host, so the runbook step "raise &lt;code&gt;JournalMaxTotalBytesMb&lt;/code&gt;" is not available.&lt;br&gt;
Read "Isolating callers by principal" below as a design, not shipped behavior.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In my &lt;a href="https://dev.to/__2d3e61e/what-happens-after-a-write-reworking-squirixs-wal-in-preview6-5ha4"&gt;preview.6 article&lt;/a&gt;, I wrote about what happens after a write is accepted: binary journal frames, group commit, crash recovery, and durable retries. That work made the durability boundaries easier to name.&lt;/p&gt;

&lt;p&gt;It does not answer the next uncomfortable question: what happens when the node should &lt;strong&gt;stop accepting&lt;/strong&gt; more durable work?&lt;/p&gt;

&lt;p&gt;A journal that never refuses appends will eventually fill the disk. A shared concurrency gate that never distinguishes callers will let one noisy tenant starve everyone else. From the outside, both failures can look like "the cache is down," even while the process is still alive.&lt;/p&gt;

&lt;p&gt;Those questions shaped &lt;code&gt;0.1.0-preview.7&lt;/code&gt;: journal disk quotas that reject durable writes with a stable error, and per-principal backpressure keyed by JWT subject (or connection id when there is no subject).&lt;/p&gt;

&lt;p&gt;Squirix is still an experimental preview, not a production-ready cache. Its APIs and storage formats may change during &lt;code&gt;0.x&lt;/code&gt;. This article describes the current design and the reasoning behind it, not a compatibility promise.&lt;/p&gt;

&lt;h2&gt;
  
  
  The failure mode we wanted to avoid
&lt;/h2&gt;

&lt;p&gt;Imagine a node that keeps appending journal segments until the volume is full. Depending on the OS and I/O path, the next write might throw, hang, or leave a torn tail. Operators then see process crashes, opaque I/O exceptions, and readiness flaps that take the node out of load balancers — exactly when health and metrics are most useful.&lt;/p&gt;

&lt;p&gt;The contract we want instead is boring and explicit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;journal on-disk size approaches configured cap
                |
                v
durable append that would exceed the cap is rejected
                |
                v
client gets JOURNAL_DISK_QUOTA
(gRPC ResourceExhausted)
                |
                v
/health/ready stays healthy
/health/ready/details exposes journalDisk pressure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rejection is definitive for that attempt. The process stays up. Readiness stays scrapeable so operators can reclaim space or raise the limit without first fighting a dead host.&lt;/p&gt;

&lt;p&gt;That is different from the "commit unknown" case in preview.6. There, durable bytes may already exist and the client only saw a timeout. Here, the server refused the append before it crossed the durability boundary. Clients should not invent success; they should back off until operators reclaim headroom or raise the cap.&lt;/p&gt;

&lt;h2&gt;
  
  
  A hard cap with soft observability
&lt;/h2&gt;

&lt;p&gt;Pipelined journal settings already expose &lt;code&gt;JournalMaxTotalBytesMb&lt;/code&gt; — a hard on-disk size for &lt;strong&gt;journal segments&lt;/strong&gt;, not snapshots or manifests. Preview.7 maps that cap into controlled write rejection. Segment-count and per-segment size caps can also reject with the same &lt;code&gt;JOURNAL_DISK_QUOTA&lt;/code&gt; code.&lt;/p&gt;

&lt;p&gt;The soft high-water for readiness details is fixed at 80% of the hard limit. Soft high-water is observability only: writes that still fit under the hard cap continue. Hard limit (&lt;code&gt;critical&lt;/code&gt;) is the observed state when &lt;code&gt;usedBytes &amp;gt;= maxBytes&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0% -------- 80% (high) -------- 100% (critical / hard cap)
|              |                      |
|   writes OK  |  writes OK if fit;   |  writeRejectionActive=true
|              |  oversize append     |  (usage already at cap)
|              |  still rejected      |
|              |  with JOURNAL_DISK_  |
|              |  QUOTA               |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important timing detail: rejection uses &lt;code&gt;usedBytes + appendBytes &amp;gt; maxBytes&lt;/code&gt;. An append can therefore be rejected while &lt;code&gt;state&lt;/code&gt; is still &lt;code&gt;high&lt;/code&gt; and &lt;code&gt;writeRejectionActive&lt;/code&gt; is still &lt;code&gt;false&lt;/code&gt;. &lt;code&gt;writeRejectionActive&lt;/code&gt; becomes &lt;code&gt;true&lt;/code&gt; only once usage has already reached the hard cap.&lt;/p&gt;

&lt;p&gt;A few details matter in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The quota covers journal segments only.&lt;/li&gt;
&lt;li&gt;Rejected durable writes do not crash the process.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/health/ready&lt;/code&gt; remains healthy so the node can still expose pressure state.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/health/ready/details&lt;/code&gt; includes &lt;code&gt;journalDisk&lt;/code&gt; with &lt;code&gt;state&lt;/code&gt;, &lt;code&gt;maxBytes&lt;/code&gt;, &lt;code&gt;usedBytes&lt;/code&gt;, &lt;code&gt;highWaterBytes&lt;/code&gt;, and &lt;code&gt;writeRejectionActive&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The operator path is intentionally unexciting: confirm pressure, trigger or wait for snapshot plus compaction/retention, raise &lt;code&gt;JournalMaxTotalBytesMb&lt;/code&gt; only after confirming disk capacity (not configurable in preview.7, see the update above), and treat &lt;code&gt;JOURNAL_DISK_QUOTA&lt;/code&gt; like other capacity rejections.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why readiness stays healthy under quota
&lt;/h2&gt;

&lt;p&gt;It is tempting to mark a node not-ready when the journal is full. That can remove it from traffic, but it also removes the cheapest way to inspect &lt;em&gt;why&lt;/em&gt; durable writes stopped.&lt;/p&gt;

&lt;p&gt;Preview.7 keeps &lt;code&gt;/health/ready&lt;/code&gt; healthy and puts pressure into details:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;load balancer / orchestrator
        |
        | GET /health/ready           --&amp;gt; 200 (still ready)
        |
        | GET /health/ready/details
        v
  journalDisk.state = critical
  writeRejectionActive = true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cache clients already receive gRPC &lt;code&gt;ResourceExhausted&lt;/code&gt; with public code &lt;code&gt;JOURNAL_DISK_QUOTA&lt;/code&gt;. That is the write-path signal. Readiness is the operator-path signal. Mixing them turns every capacity event into a membership event.&lt;/p&gt;

&lt;p&gt;HTTP on the primary listener is limited to health and metrics in v0.1; there is no public REST cache mutation surface. Shared error helpers can project the same logical error as HTTP 429 in tests and internal adapters, but application clients should key off the gRPC status and &lt;code&gt;JOURNAL_DISK_QUOTA&lt;/code&gt; code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Backpressure is not memory pressure
&lt;/h2&gt;

&lt;p&gt;Squirix already separates several admission policies. Preview.7 does not merge them; it makes one of them fairer under multi-tenant load.&lt;/p&gt;

&lt;p&gt;Transport limits still protect auth, payload size, and deadlines. Memory pressure still admits work based on estimated cache size. Journal disk quota still protects on-disk journal growth. Runtime backpressure protects concurrent cache operations, queues, slowdown, and optional rate limits.&lt;/p&gt;

&lt;p&gt;Runtime backpressure sits after validation and before memory admission. A rejection there happens before logical cache operations enter memory admission or clustered/local paths, so rejected work does not append journal records, mutate local memory, update memory accounting, or record idempotency outcomes.&lt;/p&gt;

&lt;p&gt;That is the same "fail closed before durability" idea as memory admission — applied to concurrency and rate, not to estimated bytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Isolating callers by principal
&lt;/h2&gt;

&lt;p&gt;Global in-flight and queue limits protect the node. They do not stop one authenticated client from consuming the whole budget.&lt;/p&gt;

&lt;p&gt;Preview.7 resolves a backpressure client id for each cache operation. The per-client concurrency and rate limits designed to apply against that id are not enabled in the shipped host (see the update above):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;request
  |
  +--&amp;gt; HttpContext missing? ----------- yes --&amp;gt; runtime
  |
  +--&amp;gt; authenticated subject? --------- yes --&amp;gt; jwt:{subject}
  |
  +--&amp;gt; connection id present? --------- yes --&amp;gt; conn:{connectionId}
  |
  +-------------------------------------------&amp;gt; runtime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Authenticated external callers with a subject land in &lt;code&gt;jwt:{subject}&lt;/code&gt; (&lt;code&gt;NameIdentifier&lt;/code&gt;, then inbound &lt;code&gt;sub&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Anonymous or subject-less HTTP callers land in &lt;code&gt;conn:{connectionId}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In-process callers without an &lt;code&gt;HttpContext&lt;/code&gt; share one &lt;code&gt;runtime&lt;/code&gt; bucket.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;v0.1 external auth is JWT-only. Inter-node cluster forwarding uses mTLS on the internal listener and typically lands in the &lt;code&gt;conn:&lt;/code&gt; or &lt;code&gt;runtime&lt;/code&gt; bucket rather than a shared external JWT subject. That is deliberate: external tenant isolation should not treat owner-forwarded RPCs as one giant client.&lt;/p&gt;

&lt;p&gt;Anonymous loopback clients on distinct TCP connections also do not share one JWT principal bucket. Without a principal, connection identity is the best stable key the host has.&lt;/p&gt;

&lt;h2&gt;
  
  
  What preview.7 changes
&lt;/h2&gt;

&lt;p&gt;The pressure work in &lt;code&gt;0.1.0-preview.7&lt;/code&gt; includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mapping the journal total-size hard cap to controlled durable write rejection (&lt;code&gt;JOURNAL_DISK_QUOTA&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;exposing soft high-water (80%) on readiness details without blocking writes that still fit;&lt;/li&gt;
&lt;li&gt;keeping readiness healthy under quota so pressure remains observable;&lt;/li&gt;
&lt;li&gt;keying per-client backpressure off JWT subject, then connection id, then the shared &lt;code&gt;runtime&lt;/code&gt; bucket (the per-client limits themselves are not enabled, see the update above);&lt;/li&gt;
&lt;li&gt;tightening path validation and symlink helpers, and clearing analyzer/Sonar debt on client and server hot paths.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of that is housekeeping. Most of it exists because awkward timing is not only about crashes. A full volume, a noisy neighbor, or a readiness flap at the wrong moment can erase the operational story as thoroughly as a torn journal frame.&lt;/p&gt;

&lt;h2&gt;
  
  
  What preview.7 does not promise
&lt;/h2&gt;

&lt;p&gt;This work makes overload and disk exhaustion easier to reason about, but Squirix is still early software.&lt;/p&gt;

&lt;p&gt;Quotas are per node and cover journal segments on that node; there is no cluster-wide disk accountant. In-process callers share &lt;code&gt;runtime&lt;/code&gt;, and internal mTLS paths are not the same as external JWT tenants. Quota buys a clear error and time to act; it is not a substitute for capacity planning, compaction, backups, or recovery testing.&lt;/p&gt;

&lt;p&gt;Preview.7 is stronger operator-facing pressure control on top of the preview.6 durability foundation, not a production-readiness declaration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing thought
&lt;/h2&gt;

&lt;p&gt;Durability work asks: what survives a crash? Pressure work asks: what happens when survival is no longer free?&lt;/p&gt;

&lt;p&gt;A journal that always accepts appends will eventually lose the ability to flush cleanly. A concurrency gate that treats every caller as interchangeable will eventually amplify a noisy neighbor into a whole-node outage.&lt;/p&gt;

&lt;p&gt;The difficult part is naming the refusal precisely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rejected before durability (journal quota and backpressure both fail closed early);&lt;/li&gt;
&lt;li&gt;rejected for this principal only when the signal is backpressure — journal disk quota remains node-wide;&lt;/li&gt;
&lt;li&gt;still ready enough to inspect;&lt;/li&gt;
&lt;li&gt;safe for clients to treat as definitive for that attempt.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Preview.7 makes those refusals more explicit. That gives operators a capacity policy instead of unexplained I/O chaos, and it gives future multi-tenant work a clearer place to hang fairness without rewriting the journal story.&lt;/p&gt;

&lt;p&gt;If you operate multi-tenant .NET services or care about cache overload semantics, I would be glad to hear where this model still surprises you. Feedback on quota versus readiness, JWT versus connection isolation, and client reactions to &lt;code&gt;JOURNAL_DISK_QUOTA&lt;/code&gt; is especially welcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix" rel="noopener noreferrer"&gt;Squirix on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/releases/tag/v0.1.0-preview.7" rel="noopener noreferrer"&gt;Release &lt;code&gt;v0.1.0-preview.7&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/main/docs/release-notes/v0.1.0.md" rel="noopener noreferrer"&gt;Squirix 0.1.0 release notes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/__2d3e61e/what-happens-after-a-write-reworking-squirixs-wal-in-preview6-5ha4"&gt;What happens after a write? (preview.6)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/main/docs/operational-runbook.md#journal-disk-quota" rel="noopener noreferrer"&gt;Journal disk quota runbook&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/squirix/squirix/blob/main/docs/configuration.md#backpressure" rel="noopener noreferrer"&gt;Backpressure configuration&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package squirix &lt;span class="nt"&gt;--version&lt;/span&gt; 0.1.0-preview.7
dotnet add package squirix.server &lt;span class="nt"&gt;--version&lt;/span&gt; 0.1.0-preview.7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>dotnet</category>
      <category>distributedsystems</category>
      <category>csharp</category>
      <category>opensource</category>
    </item>
    <item>
      <title>What happens after a write? Reworking Squirix's WAL in preview.6</title>
      <dc:creator>Alex E</dc:creator>
      <pubDate>Sun, 19 Jul 2026 07:51:43 +0000</pubDate>
      <link>https://dev.to/alexander-efremov/what-happens-after-a-write-reworking-squirixs-wal-in-preview6-5ha4</link>
      <guid>https://dev.to/alexander-efremov/what-happens-after-a-write-reworking-squirixs-wal-in-preview6-5ha4</guid>
      <description>&lt;p&gt;In my&lt;br&gt;
&lt;a href="https://dev.to/__2d3e61e/why-squirix-uses-a-strict-clientserver-architecture-for-a-net-distributed-cache-5086"&gt;first Squirix article&lt;/a&gt;,&lt;br&gt;
I wrote about why Squirix keeps a strict boundary between the client and the server. Applications use a typed client&lt;br&gt;
over gRPC; the server owns cache state, routing, persistence, recovery, and operational endpoints.&lt;/p&gt;

&lt;p&gt;That boundary makes ownership clear. It does not answer the uncomfortable question underneath it: what exactly happens&lt;br&gt;
between accepting a write and telling the client it succeeded?&lt;/p&gt;

&lt;p&gt;Preview.6 goes one level deeper into that path. What if the process dies after writing to disk but before sending the&lt;br&gt;
response? What survives a torn journal tail? How can a client retry without applying the same mutation twice?&lt;/p&gt;

&lt;p&gt;Those questions shaped the release: a pipelined binary write-ahead log, tighter snapshot and journal recovery, and&lt;br&gt;
idempotent mutation outcomes that survive a restart.&lt;/p&gt;

&lt;p&gt;Squirix is still an experimental preview, not a production-ready cache. Its APIs and storage formats may change during&lt;br&gt;
&lt;code&gt;0.x&lt;/code&gt;. This article describes the current design and the reasoning behind it, not a compatibility promise.&lt;/p&gt;
&lt;h2&gt;
  
  
  Follow one write
&lt;/h2&gt;

&lt;p&gt;The basic ordering rule is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Append the mutation to the journal before applying it in memory, and do not return success before the required&lt;br&gt;
durability boundary.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For a normal durable mutation, the path looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;validate and admit the mutation
            |
            v
append a binary WAL record
            |
            v
cross the configured durability boundary
            |
            v
apply the mutation in memory
            |
            v
return success
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order is deliberate. If the server changed memory first and appended to the journal afterward, a crash in between&lt;br&gt;
could make an acknowledged write disappear after restart.&lt;/p&gt;

&lt;p&gt;Idempotent RPCs take one deliberate variation. Squirix appends the mutation, applies it in memory to produce the&lt;br&gt;
response, appends that response as an idempotency outcome, then waits for a single durability boundary covering both&lt;br&gt;
records. The response is not returned before that wait completes.&lt;/p&gt;

&lt;p&gt;The mutation and its retry result share one durability commit, without pretending the network response is atomic with&lt;br&gt;
the disk write.&lt;/p&gt;

&lt;p&gt;Journal-first ordering avoids acknowledged-but-unrecoverable writes, but it exposes a different case. Suppose the&lt;br&gt;
journal becomes durable and the process dies before the response reaches the client. Recovery may replay the mutation&lt;br&gt;
even though the client observed only a timeout or broken connection.&lt;/p&gt;

&lt;p&gt;That outcome is not an ordinary failure. It is &lt;strong&gt;commit unknown&lt;/strong&gt;: the operation may have committed, but the client did&lt;br&gt;
not receive a definitive answer.&lt;/p&gt;

&lt;p&gt;This is different from a rejection before the journal. If the memory-admission gate rejects a growing entry, Squirix&lt;br&gt;
has not appended anything and has not changed cache state. That rejection is definitive. Once durable bytes may exist,&lt;br&gt;
the answer has to be more careful.&lt;/p&gt;
&lt;h2&gt;
  
  
  Moving file I/O off request threads
&lt;/h2&gt;

&lt;p&gt;Preview.6 replaces the previous journal path with a pipelined binary WAL backend. The goal was not simply to make file&lt;br&gt;
writes faster. It was to give journal work one owner and make backpressure visible.&lt;/p&gt;

&lt;p&gt;Request threads do not independently open files, encode records, and call &lt;code&gt;fsync&lt;/code&gt;. They submit append work to a bounded&lt;br&gt;
ring. A dedicated background thread named &lt;code&gt;squirix-journal-io&lt;/code&gt; owns the journal event loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;request threads
   |    |    |
   v    v    v
+-------------------+
| bounded WAL ring  |
+-------------------+
          |
          v
+------------------------+
| single journal thread  |
+------------------------+
          |
          v
   binary WAL segments
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The journal thread drains accepted work, encodes and batches frames, writes segment bytes, services durability&lt;br&gt;
deadlines, performs flushes, and coordinates segment rolls.&lt;/p&gt;

&lt;p&gt;The queue is bounded because storage can always fall behind incoming traffic. An unbounded queue would turn that&lt;br&gt;
mismatch into unbounded memory growth; the ring turns it into visible backpressure instead.&lt;/p&gt;

&lt;p&gt;The single writer also gives segment state one clear owner. Offsets, batches, durability state, and roll decisions do&lt;br&gt;
not need to be coordinated among arbitrary request threads.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why the journal is binary
&lt;/h2&gt;

&lt;p&gt;The new WAL writes binary frames rather than passing persistence records through JSON text.&lt;/p&gt;

&lt;p&gt;That gives the storage path predictable record sizes, explicit field validation, CRC32C checksums, and span-based&lt;br&gt;
encoding for the hot parts of the format. It also makes versioning a property of the storage format rather than an&lt;br&gt;
accidental consequence of a general-purpose serializer.&lt;/p&gt;

&lt;p&gt;This is partly a performance choice, but the main benefit is control. Recovery needs to distinguish a complete record&lt;br&gt;
from arbitrary bytes at the end of a file. A framed binary format can say exactly how long a record is and whether its&lt;br&gt;
checksum is valid.&lt;/p&gt;

&lt;p&gt;The event loop also coalesces encoded records into write batches. Writing bytes and declaring those bytes durable are&lt;br&gt;
separate steps, which is where group commit enters the design.&lt;/p&gt;
&lt;h2&gt;
  
  
  Sharing an &lt;code&gt;fsync&lt;/code&gt; with group commit
&lt;/h2&gt;

&lt;p&gt;Flushing every mutation separately gives straightforward semantics, but it also makes each request pay the full&lt;br&gt;
durability cost.&lt;/p&gt;

&lt;p&gt;With group commit enabled, several appends can share one flush:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;append A ─┐
append B ─┼── write batch ── fsync ── complete A, B, and C
append C ─┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each waiter is completed only after a durability flush covers the relevant appends. The journal thread flushes the&lt;br&gt;
current write batch, performs the storage flush, and then completes the captured batch of waiters. If the flush fails,&lt;br&gt;
every waiter in that batch fails; no caller is told that partial durability was enough.&lt;/p&gt;

&lt;p&gt;The group is bounded by configuration—a maximum wait and a maximum batch size—trading a small, controlled delay for&lt;br&gt;
fewer durability flushes. Workloads that prefer the strictest per-write latency can disable group commit.&lt;/p&gt;

&lt;p&gt;The important contract is not merely that an &lt;code&gt;fsync&lt;/code&gt; happened somewhere. It is that a completed waiter is covered by&lt;br&gt;
that durability flush.&lt;/p&gt;
&lt;h2&gt;
  
  
  The response can still get lost
&lt;/h2&gt;

&lt;p&gt;Even with correct WAL ordering, the server cannot make the network response atomic with the disk write.&lt;/p&gt;

&lt;p&gt;The failure window is easiest to see as a short sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. append operation A
2. flush operation A
3. crash before the response reaches the client
4. recover operation A from the WAL
5. client retries operation A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without a stable request identity, step 5 could apply the same logical mutation twice. The risk is greatest for&lt;br&gt;
mutations whose effect is not naturally idempotent.&lt;/p&gt;

&lt;p&gt;Squirix mutation RPCs therefore carry an opaque &lt;code&gt;operation_id&lt;/code&gt;. The server associates the ID with a request fingerprint&lt;br&gt;
and the serialized response. A retry with the same ID and fingerprint can return the original result. Reusing the ID&lt;br&gt;
for a different request is rejected.&lt;/p&gt;

&lt;p&gt;In preview.6, that identity survives restart. Recovery rebuilds successful durable outcomes from operation metadata in&lt;br&gt;
the journal and from retained idempotency records in snapshots. The operation ID is also preserved when a receiving&lt;br&gt;
node forwards a mutation to the key owner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client
  |
  | operation_id = 4f...
  v
receiving node
  |
  | same operation_id
  v
owner node
  |
  +--&amp;gt; durable mutation record
  |
  +--&amp;gt; durable outcome metadata
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is not a distributed transaction, and I will not present it as one. It gives a supported mutation a stable identity&lt;br&gt;
across forwarding, timeouts, retries, and restarts—exactly the situations where commit unknown becomes operationally&lt;br&gt;
important.&lt;/p&gt;
&lt;h2&gt;
  
  
  Recovery starts by distrusting the files
&lt;/h2&gt;

&lt;p&gt;A snapshot is not valid merely because a file with the right name exists. Squirix reads and validates the complete&lt;br&gt;
snapshot into a temporary load result before applying its entries. The startup gate remains closed until snapshot&lt;br&gt;
restore and journal replay have both completed.&lt;/p&gt;

&lt;p&gt;The current recovery flow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read the manifest.&lt;/li&gt;
&lt;li&gt;Locate the referenced snapshot.&lt;/li&gt;
&lt;li&gt;Decode cache entries and retained idempotency records into a temporary load result.&lt;/li&gt;
&lt;li&gt;Validate the complete snapshot.&lt;/li&gt;
&lt;li&gt;Apply the validated snapshot state.&lt;/li&gt;
&lt;li&gt;Replay journal records after the snapshot watermark.&lt;/li&gt;
&lt;li&gt;Open the startup gate.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;manifest
   |
   v
snapshot ── validate all frames ── apply recovered state
   |
   v
last applied sequence N
   |
   v
replay WAL records where sequence &amp;gt; N
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The watermark matters. A snapshot represents state through a particular journal sequence. Replaying records at or&lt;br&gt;
before that sequence would apply mutations twice; skipping later records would lose committed state.&lt;/p&gt;

&lt;p&gt;Preview.6 freezes the metadata that describes the snapshot cut so that the entries and their sequence boundary refer&lt;br&gt;
to the same logical point.&lt;/p&gt;

&lt;p&gt;Snapshot publication follows the usual temporary-file pattern: write and flush a temporary file, publish the completed&lt;br&gt;
snapshot, and only then update the manifest reference. A crash during the temporary write must not make an incomplete&lt;br&gt;
snapshot authoritative.&lt;/p&gt;

&lt;p&gt;If the referenced snapshot is missing, unreadable, truncated, or fails checksum validation, Squirix discards all&lt;br&gt;
snapshot-derived state. It falls back to journal-only recovery only when the required journal history is still&lt;br&gt;
available. Otherwise recovery fails instead of guessing across a gap. Preview.6 also fixes the valid fallback path so&lt;br&gt;
replay starts from the earliest available segment when there is no snapshot watermark.&lt;/p&gt;
&lt;h2&gt;
  
  
  A torn tail does not erase the valid prefix
&lt;/h2&gt;

&lt;p&gt;A process can stop halfway through the final WAL frame. Recovery must not interpret those bytes as a complete mutation,&lt;br&gt;
but it should not discard every earlier record either.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[valid frame][valid frame][valid frame][partial bytes...]
                                      ^
                               recovery stops here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Journal replay proceeds through complete, validated records in segment order. During startup, Squirix scans the active&lt;br&gt;
segment to the last valid frame boundary and truncates an incomplete tail before reopening it for writes.&lt;/p&gt;

&lt;p&gt;This is intentionally conservative:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;never invent a record from partial bytes;&lt;/li&gt;
&lt;li&gt;never replay beyond an invalid boundary;&lt;/li&gt;
&lt;li&gt;preserve the valid committed prefix.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same principle applies to snapshots: do not start applying entries until the complete file has been decoded and&lt;br&gt;
validated. A clean journal fallback is easier to reason about than trusting a partly decoded snapshot.&lt;/p&gt;
&lt;h2&gt;
  
  
  Compaction must preserve retry semantics
&lt;/h2&gt;

&lt;p&gt;Compaction cannot keep only the latest key/value state.&lt;/p&gt;

&lt;p&gt;Imagine that operation A committed, its result was retained for deduplication, and old journal segments were then&lt;br&gt;
compacted away. If the snapshot contained cache values but not the idempotency record, a delayed retry of A could lose&lt;br&gt;
its original identity and execute again.&lt;/p&gt;

&lt;p&gt;Snapshots therefore include retained idempotency outcomes alongside cache entries. After compaction and restart,&lt;br&gt;
Squirix needs to recover both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cache state
+
retry identity and durable outcomes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Durability is not only the ability to reconstruct values. It also means reconstructing enough protocol state to handle&lt;br&gt;
uncertain retries safely.&lt;/p&gt;

&lt;h2&gt;
  
  
  What preview.6 changes
&lt;/h2&gt;

&lt;p&gt;The durability work in &lt;code&gt;0.1.0-preview.6&lt;/code&gt; includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a pipelined binary WAL;&lt;/li&gt;
&lt;li&gt;a dedicated single-writer journal event loop;&lt;/li&gt;
&lt;li&gt;bounded append backpressure;&lt;/li&gt;
&lt;li&gt;configurable group commit;&lt;/li&gt;
&lt;li&gt;journal-only recovery from the earliest available segment when the journal topology is valid;&lt;/li&gt;
&lt;li&gt;a stable snapshot cut and replay watermark;&lt;/li&gt;
&lt;li&gt;durable operation outcomes across restart;&lt;/li&gt;
&lt;li&gt;operation-ID propagation between nodes;&lt;/li&gt;
&lt;li&gt;retained idempotency records in snapshots;&lt;/li&gt;
&lt;li&gt;compaction cancellation during shutdown;&lt;/li&gt;
&lt;li&gt;lower allocation pressure on WAL hot paths.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some changes improve throughput. Most exist because of awkward timing: a crash after a journal flush, a lost response,&lt;br&gt;
a truncated final frame, compaction followed by an old retry, or shutdown while persistence work is active.&lt;/p&gt;

&lt;p&gt;That is where durability engineering lives. The happy path is necessary, but it is rarely the part that keeps me&lt;br&gt;
thinking after the code is written.&lt;/p&gt;

&lt;h2&gt;
  
  
  What preview.6 does not promise
&lt;/h2&gt;

&lt;p&gt;This work makes the durability model easier to reason about, but Squirix is still early software.&lt;/p&gt;

&lt;p&gt;The on-disk format may change during &lt;code&gt;0.x&lt;/code&gt;. Durability is per node; preview.6 does not add replication or automatic&lt;br&gt;
failover. Operations spanning multiple owners are not globally atomic transactions. Serializer compatibility and&lt;br&gt;
restart behavior still need to be validated for the mutation paths a workload depends on.&lt;/p&gt;

&lt;p&gt;A WAL is not a substitute for replication, backups, or recovery testing. Preview.6 is a stronger durability foundation,&lt;br&gt;
not a production-readiness declaration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing thought
&lt;/h2&gt;

&lt;p&gt;Appending bytes is the easy part of a write-ahead log. Deciding what those bytes mean after a crash is the real work.&lt;/p&gt;

&lt;p&gt;The difficult part is naming every boundary precisely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;accepted;&lt;/li&gt;
&lt;li&gt;appended;&lt;/li&gt;
&lt;li&gt;flushed;&lt;/li&gt;
&lt;li&gt;applied in memory;&lt;/li&gt;
&lt;li&gt;visible to the client;&lt;/li&gt;
&lt;li&gt;recoverable after restart;&lt;/li&gt;
&lt;li&gt;safe to retry.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Preview.6 makes those boundaries more explicit. That gives future work—replication, failover, and more advanced cluster&lt;br&gt;
behavior—a durability model it can build on instead of work around.&lt;/p&gt;

&lt;p&gt;If you work on storage engines or distributed .NET systems, I would be glad to hear where you think the remaining sharp&lt;br&gt;
edges are. The project is open source, and feedback on the WAL, recovery semantics, and retry model is especially&lt;br&gt;
welcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix" rel="noopener noreferrer"&gt;Squirix on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/squirix/squirix/blob/main/docs/release-notes/v0.1.0.md" rel="noopener noreferrer"&gt;Squirix 0.1.0 release notes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>distributedsystems</category>
      <category>squirix</category>
    </item>
    <item>
      <title>Why Squirix uses a strict client/server architecture for a .NET distributed cache</title>
      <dc:creator>Alex E</dc:creator>
      <pubDate>Sun, 07 Jun 2026 07:12:52 +0000</pubDate>
      <link>https://dev.to/alexander-efremov/why-squirix-uses-a-strict-clientserver-architecture-for-a-net-distributed-cache-5086</link>
      <guid>https://dev.to/alexander-efremov/why-squirix-uses-a-strict-clientserver-architecture-for-a-net-distributed-cache-5086</guid>
      <description>&lt;p&gt;Squirix 0.1.0 is an early preview of a .NET distributed cache. A typed client SDK talks to a remote server over gRPC; the server owns state, routing, durability, and operational endpoints.&lt;/p&gt;

&lt;p&gt;This is the direction I am validating in 0.1.0 — not a claim that every cache must work this way. Embedded designs are fine for many workloads. Squirix targets a different shape: &lt;strong&gt;the application stays a client; the server owns the data lifecycle.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with "just a cache library"
&lt;/h2&gt;

&lt;p&gt;A cache library is simple until you ask who owns what. When cache logic runs inside your app process, state, memory pressure, and persistence share the app's lifecycle. That works for local acceleration (&lt;code&gt;IMemoryCache&lt;/code&gt;), but gets ambiguous when you need shared state across instances, durability across restarts, independent health/metrics, or cluster routing.&lt;/p&gt;

&lt;p&gt;At that point you often have an implicit server with unclear boundaries. Squirix makes the split explicit from day one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Embedded mode vs client/server mode
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Embedded&lt;/strong&gt; — cache logic in or tightly coupled to the app process: in-memory caches, libraries that hide remote I/O, or a co-located server called via direct references. Low friction; you rarely expect separate health probes or journal compaction on "just a dependency."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client/server&lt;/strong&gt; — the app holds no authoritative state. It connects over a wire contract; the server owns placement, mutations, durability, recovery, and admin/metrics endpoints. Redis and most production distributed caches follow this shape.&lt;/p&gt;

&lt;p&gt;Squirix 0.1.0 is client/server first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;application -&amp;gt; Squirix client SDK -&amp;gt; Squirix.Server node(s)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two packages, enforced at build time: &lt;a href="https://www.nuget.org/packages/squirix/" rel="noopener noreferrer"&gt;&lt;code&gt;squirix&lt;/code&gt;&lt;/a&gt; (client) and &lt;code&gt;squirix.server&lt;/code&gt; (runtime). The server does not reference the client assembly.&lt;/p&gt;

&lt;p&gt;You can embed the server in ASP.NET Core via &lt;code&gt;AddSquirixServer&lt;/code&gt; / &lt;code&gt;MapSquirixServer&lt;/code&gt;, but application access still goes through &lt;code&gt;SquirixClient.ConnectAsync(...)&lt;/code&gt; — even in the same process. That is hosting convenience, not embedded cache semantics in the app layer.&lt;/p&gt;

&lt;p&gt;Embedded mode is not bad — it optimizes for different goals. Squirix targets shared remote state, server-owned durability, and operability as infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Squirix chooses client/server first
&lt;/h2&gt;

&lt;p&gt;Reasoning behind the 0.1.0 shape:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Operational boundary&lt;/strong&gt; — deploy, probe, and upgrade cache nodes independently. Health (&lt;code&gt;/health/live&lt;/code&gt;, &lt;code&gt;/health/ready&lt;/code&gt;), admin (&lt;code&gt;/admin/whoami&lt;/code&gt;, &lt;code&gt;/admin/ring&lt;/code&gt;), and Prometheus at &lt;code&gt;/metrics&lt;/code&gt; live on the server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-owned lifecycle&lt;/strong&gt; — WAL journal, snapshots, compaction, and recovery stay in &lt;code&gt;squirix.server&lt;/code&gt;, not in every application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lighter client package&lt;/strong&gt; — run the server as its own process or container; apps only reference the client SDK.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clustering path&lt;/strong&gt; — static consistent-hash routing in 0.1.0 is early, but routing and failover can evolve server-side without rewriting &lt;code&gt;ICache&amp;lt;T&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Durability isolation&lt;/strong&gt; — recovery and compaction failures stay out of application request threads while semantics harden.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How this affects the public API
&lt;/h2&gt;

&lt;p&gt;You connect via &lt;code&gt;SquirixClient.ConnectAsync(...)&lt;/code&gt; and work with typed &lt;code&gt;ICache&amp;lt;T&amp;gt;&lt;/code&gt; and explicit read results (&lt;code&gt;CacheValueResult&amp;lt;T&amp;gt;&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Threading&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Squirix&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CancellationToken&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;None&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;var&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;SquirixClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConnectAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"http://localhost:5001"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetCacheAsync&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;"demo"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"greeting"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;lookup&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetValueAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"greeting"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Found&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Production server hosting uses &lt;code&gt;AddSquirixServer&lt;/code&gt; / &lt;code&gt;MapSquirixServer&lt;/code&gt;. Transport is &lt;strong&gt;gRPC&lt;/strong&gt; (&lt;code&gt;SquirixCache.proto&lt;/code&gt;); cache operations, health, and admin routes are also available over &lt;strong&gt;HTTP/2 REST&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What exists in Squirix 0.1.0
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;0.1.0-preview.1&lt;/code&gt;&lt;/strong&gt;, .NET 10 only:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client/server split (&lt;code&gt;squirix&lt;/code&gt; + &lt;code&gt;squirix.server&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Typed &lt;code&gt;ICache&amp;lt;T&amp;gt;&lt;/code&gt; — basic KV + expiration&lt;/li&gt;
&lt;li&gt;gRPC + HTTP/2 REST cache endpoints&lt;/li&gt;
&lt;li&gt;Per-node journal, snapshots, compaction, recovery&lt;/li&gt;
&lt;li&gt;Health, readiness, admin routes; Prometheus metrics; OpenTelemetry journal tracing&lt;/li&gt;
&lt;li&gt;Static consistent-hash single-owner routing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For local h2c dev: &lt;code&gt;$env:DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_HTTP2UNENCRYPTEDSUPPORT = "1"&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is still experimental
&lt;/h2&gt;

&lt;p&gt;Early preview — &lt;strong&gt;not production-ready&lt;/strong&gt;. API, wire format, and on-disk layouts may change during 0.x.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/squirix/squirix" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; · &lt;a href="https://www.nuget.org/packages/squirix/" rel="noopener noreferrer"&gt;NuGet&lt;/a&gt; · &lt;a href="https://github.com/squirix/squirix/blob/main/docs/release-notes/v0.1.0.md" rel="noopener noreferrer"&gt;Release notes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/squirix/squirix/blob/main/docs/architecture.md" rel="noopener noreferrer"&gt;Architecture&lt;/a&gt; · &lt;a href="https://github.com/squirix/squirix/blob/main/docs/server-mode.md" rel="noopener noreferrer"&gt;Server mode&lt;/a&gt; · &lt;a href="https://github.com/squirix/squirix/blob/main/docs/diagnostics.md" rel="noopener noreferrer"&gt;Diagnostics&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>distributedsystems</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
