<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Architecture on Mimus</title><link>https://mimus.pgsty.com/docs/etcd/architecture/</link><description>Recent content in Architecture on Mimus</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 06 Dec 2026 15:37:05 +0800</lastBuildDate><atom:link href="https://mimus.pgsty.com/docs/etcd/architecture/index.xml" rel="self" type="application/rss+xml"/><item><title>Security</title><link>https://mimus.pgsty.com/docs/etcd/architecture/security/</link><guid>https://mimus.pgsty.com/docs/etcd/architecture/security/</guid><description>&lt;p&gt;A pgetcd gateway process authenticates one tenant principal over mTLS and connects to that tenant&amp;rsquo;s fixed PostgreSQL database using a restricted SQL role. It does not implement the etcd &lt;code&gt;Auth&lt;/code&gt; service, RBAC roles, or per-key authorization.&lt;/p&gt;&#10;&lt;h2 id="client"&gt;Client to gateway&#10;&lt;/h2&gt;&#10;&lt;p&gt;The gRPC listener requires TLS 1.2 or later and a verified client certificate (&lt;code&gt;RequireAndVerifyClientCert&lt;/code&gt;). After X.509 chain verification against &lt;code&gt;tls.client_ca_file&lt;/code&gt;, the gateway requires an exact URI Subject Alternative Name (SAN) match with the tenant&amp;rsquo;s configured &lt;code&gt;tls.client_uri&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Schema</title><link>https://mimus.pgsty.com/docs/etcd/architecture/schema/</link><guid>https://mimus.pgsty.com/docs/etcd/architecture/schema/</guid><description>&lt;p&gt;&lt;code&gt;pg_etcd&lt;/code&gt; installs the &lt;code&gt;etcd&lt;/code&gt; schema in each tenant database. All seven persistent tables are regular WAL-logged PostgreSQL tables. The extension&amp;rsquo;s SQL installation file defines schema version &lt;code&gt;2&lt;/code&gt;, while the JSONB request envelope uses internal SQL ABI version &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#10;&lt;h2 id="tables"&gt;Tables&#10;&lt;/h2&gt;&#10;&lt;div class="td-table-scroll td-table-scroll--static"&gt;&#10;&lt;table class="wide td-table--wide"&gt;&#10; &lt;thead&gt;&#10; &lt;tr&gt;&#10; &lt;th scope="col"&gt;Table&lt;/th&gt;&#10; &lt;th scope="col"&gt;Contents and invariant&lt;/th&gt;&#10; &lt;/tr&gt;&#10; &lt;/thead&gt;&#10; &lt;tbody&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;&lt;code&gt;etcd.meta&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Single serialization row (&lt;code&gt;singleton = true&lt;/code&gt;). Stores current revision &lt;code&gt;R&lt;/code&gt;, compact revision &lt;code&gt;C&lt;/code&gt;, history floor &lt;code&gt;F&lt;/code&gt;, active &lt;code&gt;anchor_generation&lt;/code&gt;, &lt;code&gt;cluster_id&lt;/code&gt;, &lt;code&gt;member_id&lt;/code&gt;, and &lt;code&gt;schema_version&lt;/code&gt;&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;&lt;code&gt;etcd.kv&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Live binary key/value pairs (&lt;code&gt;key&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt;, &lt;code&gt;create_revision&lt;/code&gt;, &lt;code&gt;mod_revision&lt;/code&gt;, &lt;code&gt;version&lt;/code&gt;, &lt;code&gt;lease_id&lt;/code&gt;)&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;&lt;code&gt;etcd.events&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Change log ordered by &lt;code&gt;(revision, sub)&lt;/code&gt;. Stores event type (&lt;code&gt;PUT&lt;/code&gt; or &lt;code&gt;DELETE&lt;/code&gt;), current tuple fields, and complete previous tuple (&lt;code&gt;prev_*&lt;/code&gt;)&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;&lt;code&gt;etcd.revision_manifest&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Per-revision summary (&lt;code&gt;revision&lt;/code&gt;, &lt;code&gt;event_count&lt;/code&gt;, &lt;code&gt;tail_bytes&lt;/code&gt;, &lt;code&gt;watch_bytes&lt;/code&gt;) for one complete revision&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;&lt;code&gt;etcd.history_anchor&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Complete live-key baseline at floor revision &lt;code&gt;F&lt;/code&gt;, partitioned logically by &lt;code&gt;generation&lt;/code&gt;&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;&lt;code&gt;etcd.leases&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Durable Lease facts (&lt;code&gt;lease_id&lt;/code&gt;, 128-bit grant generation &lt;code&gt;grant_hi&lt;/code&gt;/&lt;code&gt;grant_lo&lt;/code&gt;, &lt;code&gt;granted_ttl_sec&lt;/code&gt;, &lt;code&gt;renew_seq&lt;/code&gt;, &lt;code&gt;attached_keys&lt;/code&gt;, &lt;code&gt;revoke_bytes&lt;/code&gt;)&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;&lt;code&gt;etcd.publication_barrier&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Single-row logged counter (&lt;code&gt;singleton = true&lt;/code&gt;, &lt;code&gt;seq&lt;/code&gt;) updated after state observations that require certification&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&#10;&lt;p&gt;Keys and values use &lt;code&gt;bytea&lt;/code&gt;. Revision and Lease ID fields use &lt;code&gt;bigint&lt;/code&gt;. Cluster and member IDs use 8-byte &lt;code&gt;bytea&lt;/code&gt; values (&lt;code&gt;cluster_id&lt;/code&gt;, &lt;code&gt;member_id&lt;/code&gt;) so the full unsigned 64-bit etcd identity is preserved without signed-integer overflow.&lt;/p&gt;</description></item><item><title>Watch, Lease and history</title><link>https://mimus.pgsty.com/docs/etcd/architecture/watch-lease/</link><guid>https://mimus.pgsty.com/docs/etcd/architecture/watch-lease/</guid><description>&lt;p&gt;Watch, Lease and history share pgetcd&amp;rsquo;s transaction and revision model. The event log in &lt;code&gt;etcd.events&lt;/code&gt; is durable. Watch cursors and Lease deadlines are runtime state derived from committed PostgreSQL facts.&lt;/p&gt;&#10;&lt;h2 id="watch"&gt;Complete revisions&#10;&lt;/h2&gt;&#10;&lt;p&gt;Each tenant gateway runs one Watch service with one concurrent tail operation. Tail v2 (&lt;code&gt;etcd._tail_v2&lt;/code&gt;), the internal event-reading interface, reads metadata, events and the revision manifest from a single snapshot. It checks the event count and encoded-size budgets, then certifies the scanned high-watermark before delivering events.&lt;/p&gt;</description></item><item><title>Transactions and revisions</title><link>https://mimus.pgsty.com/docs/etcd/architecture/transactions/</link><guid>https://mimus.pgsty.com/docs/etcd/architecture/transactions/</guid><description>&lt;p&gt;The &lt;code&gt;pg_etcd&lt;/code&gt; extension evaluates each request inside one PostgreSQL transaction. The Publisher is the gateway component that owns this transaction and holds its provisional response. It sends the response to the client only after synchronous &lt;code&gt;COMMIT&lt;/code&gt; succeeds without a warning.&lt;/p&gt;&#10;&lt;p&gt;To certify an observation, the extension writes WAL after reading that state. The Publisher then waits for synchronous &lt;code&gt;COMMIT&lt;/code&gt; before sending the result.&lt;/p&gt;&#10;&lt;h2 id="algorithm"&gt;Execution order&#10;&lt;/h2&gt;&#10;&lt;p&gt;The gateway binds the request to its configured tenant and checks input limits before execution:&lt;/p&gt;</description></item></channel></rss>