Describes what exists today. skylite is beta.
Server reference
The exact behaviour of `skylite serve` in this version. The requests it serves, the checks it runs and their order, every limit, leadership, forwarding between pods, readiness and shutdown.
This page is the precise reference for the server’s protocol and limits. To set up and run skylite, start with the quick start, Azure Blob Storage and Running in production; every configuration key is in the configuration reference.
skylite serve -config <file> runs the server. In this version it creates databases, leads the databases its configuration lists, answers the two stateless requests, query and describe, on leaders and opt-in followers, and runs autocommit writes and transactions on write channels on leaders, and serves read-only channels on leaders and on standbys with follower reads. With a peer listener configured, a pod forwards what it cannot serve to the pod that can (Forwarding between pods). The leader settles a write whose channel was lost with resolve and answers GET status. The Go driver sends query, describe, opens, channel requests, cancel, close and resolve; the JDBC driver sends query, describe, write and read-only opens, channel requests, batches among them, cancel, close and resolve. Neither driver sends describe on a channel yet.
What it serves
| Request | Answer |
|---|---|
PUT /v1/databases/{db} with body {} | 200 and {"done":{"txn":1,"epoch":1}} when it created the database; 409 database_exists when the database exists or a concurrent PUT won |
POST /v1/databases/{db}/query with sql and optionally params or named, min_txn and timeout_ms | One pure read on the leader or on an enabled follower: a columns frame, one frame per row, then done with txn, read_only, rows_affected and last_insert_rowid. See Queries |
POST /v1/databases/{db}/describe with sql and optionally min_txn | The statement’s result columns and parameter names, without running it: a columns frame, params frames, then done with txn and param_count |
POST /v1/databases/{db}/channels with {"mode":"write"}, or {"mode":"read_only"} and optionally min_txn | Opens a channel: a write channel on the leader, a read-only one on the leader or on a standby’s follower. done has txn, the owner’s head or the follower’s snapshot, and channel with token, id, mode, limits and, for a write channel, epoch. See Write channels and Read-only channels |
POST /v1/databases/{db}/channel with channel, seq and op: begin (optionally with a first statement in execute, min_txn and timeout_ms), execute (with sql, optionally params or named, min_txn and timeout_ms), batch (with sql and param_sets, or statements, optionally min_txn and timeout_ms), describe (with sql), commit (optionally timeout_ms), rollback or ping | A request on the channel: an autocommit write, a step of a transaction, or a batch or describe |
POST /v1/databases/{db}/channel/cancel with channel and seq | Cancels that request: done with seq, txn_state and the request’s receipt. See Cancel |
POST /v1/databases/{db}/channel/close with channel | Closes the channel: done with last_seq and the receipt of that request |
| Channel requests on a database this server does not lead, other than those of a read-only channel its follower owns, or stateless reads with neither a local leader nor an enabled local follower | With peer set, forwarded once to the pod that serves them (Forwarding between pods); otherwise 503 not_serving, the body unread |
POST /v1/databases/{db}/resolve with channel and seq | On the leader: done with resolution, committed, not_committed, pending or unknown, and txn. See Resolve. A pod that does not lead the database forwards it to the leader with peer set, and otherwise answers 503 not_serving |
GET /v1/databases/{db}, without a body | On the leader: done with txn, the leader’s head, epoch, sqlite_version and limits, the open answer’s. A pod that does not lead the database answers 503 not_serving: a GET is never forwarded. A GET with a body is 400 invalid_request |
| Anything else, or a path with a query string | 400 invalid_request |
{db} is 1 to 63 characters from a-z, 0-9 and -, starting with a letter or a digit. A PUT needs the admin role on the name; a write open, every request on a write channel and a resolve need the write role, checked again on each request because a new token’s claims can differ; every other request, a read-only open, a request on a read-only channel, a close and a cancel included, needs the read role. Every answer is a sequence of NDJSON frames ending in one terminal frame, and a refusal is one error frame, with the headers Skylite-Protocol: 1, Skylite-Request-Id, Content-Type: application/x-ndjson and Cache-Control: no-store; a 401 also carries WWW-Authenticate: Bearer. The error object and every code are described in Errors to handle.
A new database has 4,096-byte pages and base groups of 256 pages. When the store cannot tell whether a create landed, the answer is 500 internal, never database_exists: the database may or may not exist, and a PUT sent again answers which.
Checks before acceptance
The server runs these checks before it accepts a request, in this order, with routing before the body; a channel request’s own checks follow in Write channels:
- The header block is at most 64 KiB, to which Go’s HTTP/1.1 server adds 4 KiB of slack (otherwise
431from the HTTP layer), and arrives within 10 seconds on HTTP/1.1; the method and path are known, and the path has no query string. - Admission (Request bounds): the server has a place for the request in its bounds on concurrent requests (
429overloaded, not executed and not recorded). - The bearer token verifies, read from the headers only (
401unauthenticated). The body is never read before this. Then the principal has a place in its own bounds (429overloaded). - The principal holds
readon the name, andadminfor aPUT(403forbidden). This comes before routing and before anything that depends on whether the database exists, so the answer is the same either way. - The server must lead the database for channel requests. For
queryanddescribeit can also use an enabled local follower, and withpeerset also for a read-only open and the requests on a read-only channel that follower owns. If neither route applies and it cannot forward the request, becausepeeris not set or another pod forwarded it, it answers503not_servingwith the body unread; a hop by peer record to a pod with no follower gets410channel_lostinstead (see the failure table). A request it can forward goes through steps 6 and 7 and is then forwarded. APUTcan go to any server. - The body share of the memory budget has room for 8 ×
Content-Length, and so does the principal’s part of it (429overloaded, the body unread). The share is half the memory budget less 1 MiB, and less 32 MiB for each database indatabases: 991 MiB at a 2 GiB budget with one; a principal, an issuer and a subject, may hold a quarter of it at once. A body is charged from before its read until its response ends, so one that is declared and never sent stays charged until the 30-second body read deadline or the client’s close. A close, a cancel and a resolve are not charged: their memory is the control capacity’s, the 1 MiB taken from the share, so a full share does not refuse them. Content-Typeisapplication/json, compared without regard to case, with parameters ignored;Content-Lengthis present once, with one value, and at most the request body limit, 16 MiB unless the memory budget is below 1,026 MiB plus 64 MiB per listed database (see Connections for queries), or 4 KiB for a close, a cancel or a resolve (413request_too_largeabove it); there is noTransfer-Encoding. The whole body is read within 30 seconds and must be exactlyContent-Lengthbytes: one JSON object with only the fields its request allows, and exactly{}for aPUT. A cut body, a reset stream or a body that arrives late is400invalid_request, and nothing is created or run.- For a
queryordescribe, the server reserves a SQLite connection (429overloaded; see Connections for queries), and the leader is not in maintenance (503maintenance).
The 30-second body read deadline starts when the server has read the header block, so it also bounds a body that a refusal leaves unread. Such a refusal is answered at once. On HTTP/1.1 it carries Connection: close, and Go’s HTTP server reads and discards what is left of the body, within the same deadline, before it closes the connection.
Request bounds
A request holds its places from the end of its header block until its response ends, so a slow body, a forwarded request waiting for its answer and a waiting close all count. The pod’s places are taken before authentication, the principal’s (an issuer and a subject) right after it, before the body is read. A request whose token names a trusted issuer and a key id the server does not have waits for another request’s refresh of that issuer’s keys, up to the 10-second fetch timeout: while it waits it gives up its pod places and holds one of 64 places for such waiters per server (429 overloaded beyond them, or if the pod’s places are full when the wait ends), and it stops waiting when its client goes away. The request that runs the refresh keeps its places. A request beyond a bound gets 429 overloaded, not executed and not recorded on its channel, so it can be sent again.
| Requests | Per server | Per principal |
|---|---|---|
Every request except a close, a cancel and a resolve; query and describe included | 1,024 | 256 |
query and describe, which also count in the row above | 256 | 64 |
| Closes and cancels, which count nowhere else | 64 | 16 |
| Resolves, which count nowhere else | 64 | 16 |
Closes and cancels have capacity of their own so that the work they end cannot starve them, and resolves have their own so that the closes of a deploy cannot starve the resolves that follow it. A forwarded request counts on the pod that forwards it and again on the pod that serves it.
Connections
The server accepts at most 1,024 client connections at a time; one beyond that waits in the operating system’s listen queue until another closes. An answer must be written within 10 seconds (the response deadline), refusals included; a client that does not read it loses it and the connection, and on HTTP/2 every stream on that connection. Over TLS the connection is released up to 5 seconds later, while Go’s TLS layer tries to send its closing alert. A connection with no request running is closed after 90 seconds, on HTTP/1.1 and HTTP/2. A connection that has not yet carried a request with a verified token is closed after 10 seconds idle instead. This bounds idleness, not lifetime: a client without a token that sends a request every few seconds keeps its connection, but holds it only while it keeps sending. On HTTP/1.1 a refused request closes its connection anyway (Connection: close), so the limit matters there only before the first request, where the header deadline applies too. On HTTP/2 the idle timeout also bounds a header block that never ends. An HTTP/2 connection carries at most 16 concurrent streams. There is no limit per client address: behind a proxy or mesh one address stands for many clients.
Queries
Leading a database
For each name in databases, the server runs an office loop: it takes office when the database’s lease is free, renews the lease every third of its time to live (lease_ttl, 60 seconds by default, so every 20 seconds), and steps down when it is deposed or its leader stops. A server that does not hold office is a standby: it reads the lease at most every 5 seconds and runs a candidacy once the lease is released or expires. A database in databases need not exist: once a PUT has created it, the server takes office within its retry backoff, at most a third of the lease’s time to live.
Reading on a follower
With follower_reads on, the default when peer is set, a standby serves query and describe for its configured databases. A follower polls the durable log about every 250 ms and pins each request to one snapshot before SQLite opens it. An observation of the end of the log is usable for new snapshots for less than two seconds. When the follower has no fresh observation, it refuses with 503 not_serving. A request can wait up to 500 ms within its statement budget for a fresh generation at or above min_txn. A fresh follower that cannot reach the requested transaction in time answers 503 behind.
If compaction overtakes the pin before the response starts, the server can retry once on a newer pin within the request and catch-up budgets. If it cannot obtain a usable replacement, it answers 503 not_serving. If compaction overtakes a pin after the response starts, an internal error ends the stream. A standby that takes office keeps serving from its follower while its leader starts, stops polling once the leader serves, and starts polling again after it steps down. A standby whose leader fails to start keeps its follower.
follower_reads defaults to true when peer is set and to false without it; set it to false to serve stateless reads only on the leader. With peer set, a follower forwards to the leader a read it has no fresh snapshot for, or is still behind on, before its answer starts, and every write and channel request other than those of the read-only channels it owns (Read-only channels). Without peer, those get 503 not_serving, so more than one pod behind a Service needs peer to deliver writes. That is why the default is false without peer: a standby that serves reads is ready, so a Service would send it writes it refuses.
How a query runs
A query runs on a pooled SQLite connection of the leader or on a SQLite connection opened for one follower snapshot. Both connections have the SQL policy installed before their first statement. The server begins a read transaction, takes its snapshot’s transaction number from the engine, and compiles the statement under the policy. Before it binds or steps anything it checks, in this order:
- The policy allowed the statement (
403statement_forbidden), which is one statement (400invalid_request) that compiles (400sql_error). - SQLite’s read-only test is true for it (
409needs_channel). Nothing is executed: a write is never stepped, so no commit reaches the log. - It is not transaction control by its first keyword,
BEGIN,COMMIT,END,ROLLBACK,SAVEPOINTorRELEASE, after white space, comments, semicolons andEXPLAIN(400invalid_request). The policy itself allowsSAVEPOINT,RELEASEandROLLBACK TOinside a transaction, and the query runs inside the server’s own.
From there the statement has started executing, and the answer is 200 whatever follows: every parameter is bound exactly once (invalid_request otherwise), the rows stream as they are produced, and an error ends the body as its terminal frame. txn in done is the transaction number of the snapshot the rows were read from. The server then rolls the read transaction back.
| Limit | Value |
|---|---|
Statement time, from the end of the body read to the last row written, storage page reads included (timeout) | 30 seconds; timeout_ms lowers it |
Result size: the bytes of all frames before the terminal one (result_too_large) | 64 MiB |
Frame size; a columns frame above it fails with result_too_large | 1 MiB |
min_txn above the snapshot’s transaction number | 503 behind |
A describe compiles the statement under the same policy and makes checks 1 and 3, then answers its result columns and parameter names without binding or stepping it; any statement can be described, writes included. A statement that reaches its time limit ends with the timeout frame, also after rows were sent. A dropped connection stops a query’s rows, and a client that stops reading them holds its connection until a second after the statement time ends: the response’s write deadline is that second later, so that the statement ends first and its timeout frame can be written.
A pragma’s table-valued function, such as SELECT * FROM pragma_user_version, is compiled by SQLite when the statement first scans it, not when it is prepared, so the policy refuses it only at the first step: describe answers 200 with its columns, and query answers 200 with statement_forbidden as its terminal frame. Nothing is executed either way.
SQL policy
Every client statement, on a leader or a follower, in a query, a write or a transaction, runs under the server’s SQL policy. The policy decides what a statement may do while SQLite compiles it, so a refused statement runs nothing. Except for transaction control, what it does not allow is refused with 403 statement_forbidden, including statement types a later SQLite adds.
- Allowed:
SELECT, recursive common table expressions,INSERT,UPDATE,DELETE, creating and dropping tables, indices, views and triggers, temporary ones included,ALTER TABLEexcept the forms named below,REINDEX,ANALYZE, andSAVEPOINT,RELEASEandROLLBACK TOinside a transaction. - Transaction control is refused with
400invalid_request:BEGIN,COMMIT,ENDandROLLBACKalways, andSAVEPOINT,RELEASEandROLLBACK TOoutside a transaction. Transactions are a channel’sbegin,commitandrollbackrequests. - Files and virtual tables:
ATTACH,DETACH,VACUUM,VACUUM mainandVACUUM INTOare refused, since compacting the database is the server’s work;VACUUM tempis accepted and does nothing.CREATE VIRTUAL TABLEandDROP VIRTUAL TABLEare refused. There is no extension loading. ALTER TABLE: the forms that check the existing rows,ADD CONSTRAINT … CHECK,ADD CHECKandALTER COLUMN … SET NOT NULL, are refused. The others,RENAME TO,RENAME COLUMN,ADD COLUMN,DROP COLUMN,DROP CONSTRAINTandALTER COLUMN … DROP NOT NULL, are allowed.- Pragmas: only
table_info,table_xinfo,index_list,index_info,foreign_key_listandforeign_keysare allowed, in any letter case and any form, a table-valued function such aspragma_index_list(?)included.foreign_keysis a setting of the connection that a client may read and change; a reset turns it back on. Every other pragma is refused, among themjournal_mode,synchronous,user_version,schema_version,integrity_checkanddatabase_list. - Functions: SQLite’s core scalar, aggregate, window, date and time, math and JSON functions,
base64and theieee754functions are allowed. Refused:regexp,regexpi,unhex,json_patch,jsonb_patchand thedecimalfunctions, because one call can run for seconds and the time limit cannot interrupt it, andsqlite_log,sqlite_compileoption_get,sqlite_compileoption_used,sqlite_source_idandmatch. The two-argumenttrim,ltrimandrtrimrefuse a set of more than 64 characters to trim. Views, triggers,CHECKconstraints, defaults and generated columns may call only functions SQLite marks innocuous, sobase64, for example, works in a query but not in a view. - Temporary objects are private to the connection, hold only the client’s own data and are dropped when the connection is reset.
The policy also bounds each statement: one string or BLOB, one row’s record and one statement’s SQL text are at most 1 MiB each; an expression nests at most 18 deep, and each table in a join and each nested subquery or common table expression counts against that depth; parentheses nest at most 100 deep; a compound SELECT has at most 4 terms; triggers and foreign key actions nest at most 8 deep; a LIKE pattern is at most 4,096 bytes; and no database can be attached. SQL longer than 1 MiB, holding a NUL byte, holding no statement or holding text after its first statement is refused with 400 invalid_request before it compiles. A statement that passes one of SQLite’s limits fails with SQLite’s own error, which names the limit (sql_error). The policy’s time limit is the request’s statement time (timeout).
Connections for queries
The memory budget is three quarters of the container’s memory limit (cgroup v2 memory.max, or v1 memory.limit_in_bytes), or of GOMEMLIMIT if that is lower, and 2 GiB when neither is set; memory_budget in the configuration replaces it. It is from 384 MiB to 64 GiB. Below 1,026 MiB, plus 64 MiB for each listed database, the request body limit, advertised as request_body_bytes, is a 32nd of the body share instead of 16 MiB, so that a principal’s quarter of the share holds one body charged at 8 ×: 10.97 MiB at 768 MiB, a 1 GiB container, with one listed database. The server does not start when the budget holds fewer SQLite connections than the listed databases plus one, and its error names the least memory_budget and memory limit that would. A cgroup file it cannot read also stops it; setting memory_budget lets it start. The server logs the budget, where it came from, the body share, the request body limit and the SQLite connections at start, and warns when memory_budget is above the container’s limit. The budget charges exactly six things: request bodies, at 8 × Content-Length, within the body share, half the budget less 1 MiB and 32 MiB per listed database; the control capacity, that 1 MiB, for closes, cancels and resolves; 32 MiB per listed database for the commit headers its leader keeps for resolves; response frames larger than 1 MiB (a single large row), at their size, within the body share, while they are written; channels, within a share of 128 MiB that holds a 2 KiB receipt for each of the 16,384 channels a server may hold (32 MiB), held write results (64 MiB) and retained replay data (32 MiB); and SQLite connections, at a 64 MiB ceiling each, within the rest, at most 256. At 2 GiB the rest is 896 MiB, so the server holds at most 14 SQLite connections, less one for each database in databases, whose leader keeps a connection of its own; stateless reads and writes share them. A follower read and a write each open a fresh connection and close it when done. With every limit reached, bodies, channels and connections hold the whole budget and no more. Nothing else is charged: not HTTP connections or their header blocks, not response frames up to 1 MiB (a frame beyond the terminal one is encoded only while a request holds a SQLite connection, or replays what the channels’ share holds), and not the engine’s page cache (64 MiB per server, shared by the databases it leads or follows) or temporary files (256 MiB per led database), which must fit in what the container has beyond the budget. A principal, an issuer and a subject, may use a quarter of them at once, at least one. A query or describe that finds its principal’s share in use, or every connection in use with none idle, waits for one, first in, first out, for at most 250 ms and never past its statement time, and gets 429 overloaded if none comes; a connection that frees goes to the first waiter it fits, so a waiter held back by its own principal’s share does not hold back another principal’s. At most 256 requests wait on a server, 64 of them from one principal; one beyond either bound gets overloaded at once. A waiter whose client goes away leaves the queue and holds nothing. A follower read pins its snapshot before it waits, so it holds that pin through the wait and reads the snapshot as it was when the wait began. A write takes its connection only once it holds the write lock, so writers waiting for the lock hold none; a write granted the lock that finds no connection waits for one ahead of every waiting query, for at most 250 ms within its statement time, outside the waiting bounds since each database has one lock holder. It waits only while queries are turning those connections over, which is when one of the principal’s queries (or, if the server is full and the principal is not, any query) got a connection within the last 250 ms; behind connections held by open transactions or long reads it does not wait, because every other writer of the database waits behind the lock holder. If none comes it records overloaded (final: true, not_executed: true) and passes the lock on. An idle connection of another database is closed to make room.
A connection is reset before every reuse, so that nothing one request changed reaches the next: an open transaction is rolled back, temporary tables, views and triggers are dropped, foreign keys are enforced and the last inserted row id is cleared. A connection whose reset fails is closed and replaced. A statement that breaks its connection, by overflowing SQLite’s C stack or exhausting the connection’s memory, gets internal; the engine discards the connection without running SQLite on it again, and the leader serves on.
Write channels
A write channel lives on the leader. In this version it carries the sequenced requests begin, execute, batch, describe, commit, rollback and ping, each with channel, seq and op: an execute with no transaction open is an autocommit write of one statement, a batch with none an autocommit write of several, and the others run transactions or describe a statement. A channel holds a SQLite connection only while a request runs or a transaction is open.
Opening
An open with {"mode":"write"} needs the write role. It is refused with 429 too_many_channels, creating nothing, when the server holds 16,384 channels, the database 4,096, or the principal 256 on the database. The token is w1.<instance>.<database id>.<open head>.<secret>: the identifier this server process drew at start, the database’s 16-byte identifier in hex, the head the open answered as txn, and 256 random bits. Requests carry it in the body only. The channel identifier, 32 hex digits, is drawn separately and reveals nothing about the token. The open answer’s limits are the server’s limits.
Checks on a channel request
After the checks above, a request on a channel goes through these, in order:
- The token names this database (
400invalid_request). - It names this server process and a channel of the leader in office, or of this standby’s follower, of this principal, that has not ended (
410channel_lost). Withpeerset, a request whose token names another process was already forwarded to that process, before this check, on a leader too (Forwarding between pods). Withoutpeer, a token of another process getschannel_lost. A request of another principal leaves the channel untouched. - The channel is not closing (
channel_lost). - The sequence number: the last, recorded as cancelled before it arrived, gets that
cancelledreceipt whatever the body; the next number with nothing running is accepted; the next with a request running gets409channel_busy; the last, with the same body digest, gets409in_flightwhile it runs and its recorded outcome after; the last with another body,409sequence_conflict(final: true); a lower number409stale_sequence, a higher409sequence_gap. A refusal changes nothing. - For a
begin,executeorbatchwith no transaction open:min_txnis at most the leader’s head (503behind); on a follower’s channel, the follower pins a snapshot at or above it within 500 ms (503behind, also with no fresh observation), and the request’s connection is opened on that snapshot and closed after it. On a write channel the leader is not in maintenance (503maintenance), and the request’s SQLite connection is reserved and opened fresh after acceptance, once it holds the write lock. On a read-only channel, and for adescribewith no transaction open on either kind, the request reserves a pooled connection, as a query does (429overloaded,503maintenance). Abeginon a read-only channel first takes a place among the read-only transactions, which hold at most half the pod’s SQLite connections, rounded down (7 of 14 at the default budget), and at most the principal’s quota less one (2 of 3), each at least 1; with none free it gets429overloaded, not executed.
Then the request is accepted: its sequence number and the SHA-256 digest of its exact body are recorded, the answer is 200, and its outcome is recorded whatever it is. A field the request may not have, or a bad value, is a recorded invalid_request. ping records txn: the snapshot inside a transaction, otherwise the leader’s head.
An autocommit write
An execute waits for the database’s write lock, then runs on its own fresh connection: BEGIN IMMEDIATE, the statement under the SQL policy, then COMMIT, or ROLLBACK after any failure, so that a failed write leaves nothing, also under SQLite’s FAIL conflict action. The connection is closed after it. Transaction control is refused as for query. Every execute takes the write lock, a read included; read_only in its answer is SQLite’s read-only test. A read’s rows are held like a write’s, so a read on a channel returns at most the held-result bound, 1 MiB, and larger results need query.
The write’s commit carries a commit identifier: the first 16 bytes of SHA-256 of the whole channel token, then the sequence number as 8 bytes, big-endian. The bearer token never enters it. A write that changes no page, such as an update that matches no rows, creates no commit, and its txn is the head it ran on.
| Limit | Value |
|---|---|
Write lock wait, first in, first out (recorded busy) | 5 seconds |
Writers waiting for the lock, per database, and per database and principal (recorded busy) | 64 and 16 |
Statement time, from before check 5 (the watermark) to the commit point, the lock wait and the connection’s open included (recorded timeout) | 30 seconds; timeout_ms lowers it |
Held result: the columns and rows of a write, kept back until its commit has an outcome, per request and per server (recorded result_too_large, nothing committed) | 1 MiB and 64 MiB |
No row of a write reaches the client before its commit has an outcome. A write’s outcome maps to its answer like this; every recorded failure has final: true and not_executed: true:
| Engine outcome | Answer |
|---|---|
| Committed (a nonzero transaction number), whatever failed after | done with that txn |
| Too large for one commit object or the local WAL bound, or fenced by another leader | Recorded commit_failed |
| Maintenance (the local WAL bound), or the log at its tail bound | Recorded maintenance |
| No SQLite connection free for it once it holds the lock: its principal’s share or every connection in use | Recorded overloaded; nothing ran, and the lock passes to the next writer |
| The connection broke (stack overflow, its memory ceiling) | Recorded internal; the engine discards the connection |
| Unknown | commit_outcome_unknown, not_executed: false, not recorded; the server stops serving the database |
| The leader stopped under the write without committing it | channel_lost, not_executed: false, not recorded; the channel has ended |
| The server failed after acceptance (a defect: a panic in its own code) | channel_lost, not_executed: false, not recorded; the channel has ended, and its write lock and held rows are released |
A client that drops its connection cancels nothing: the write runs on, and its outcome is recorded for a resend to replay.
Transactions
A transaction moves its channel through three states. Every answer on a channel carries txn_state: none, open or aborted.
beginwaits for the write lock like an autocommit write, then runsBEGIN IMMEDIATEon a fresh connection, and the first statement inexecute, if any. Itstxnis the transaction’s snapshot: the head whenBEGIN IMMEDIATEreturned. The transaction then holds its connection and the database’s write lock across requests until it ends, so every other writer waits, and after the lock wait getsbusy. Abeginthat fails, in its first statement too, rolls back, closes the connection and leaves no transaction, withnot_executed: trueandtxn_state: "none": a first statement under SQLite’sFAILconflict action leaves nothing either. Abegininside a transaction recordsinvalid_state.executeinside a transaction runs on the transaction’s connection; its rows stream as they are produced, and up to 64 KiB of them are kept for replay. Its recorded failure hasnot_executed: false, whatever the code, because SQLite’s semantics apply inside the transaction. After it, the server reads SQLite’s autocommit state: when SQLite rolled the whole transaction back, as anINSERT OR ROLLBACKdoes, the answer saysaborted, and the connection and the lock are released at once.SAVEPOINT,RELEASEandROLLBACK TOrun as statements inside a transaction; outside one, and in an autocommit write, they are refused like other transaction control.commitrunsCOMMITunder the commit identifier of its own sequence number. It ends the transaction whatever happens: committed (committed: true,wrote: true,txnthe new transaction), committed with nothing to write (wrote: false,txnthe snapshot), or failed, which rolls back and records the error withnot_executed: true. A deferred foreign key that fails atCOMMITis such a failure, although SQLite itself would keep the transaction open. A commit’s outcome maps to its answer as an autocommit write’s does.rollbackrolls back, closes the connection and releases the lock; itstxnis the leader’s head. Without a transaction it recordsinvalid_state. Arollbackthat fails its validation after acceptance, one with asqlmember for example, recordsinvalid_requestand leaves the state as it was: an open transaction keeps its connection and the lock, an aborted channel holds neither and stays aborted, until a validrollback, a close or a limit ends it. A statement that succeeds after SQLite’s transaction has gone underneath it answers withtxn_state: aborted, and the lock is released.- Aborted: a channel whose transaction SQLite, a limit or the engine rolled back holds nothing, and records
transaction_aborted(not_executed: true) for every request butrollback, which returns it tonone. When the engine ended the transaction, as maintenance does, the error carriescause: "maintenance".
| Limit | Value |
|---|---|
Statement time, per request, from before check 5 to the commit point for a commit (recorded timeout). Inside a transaction an interrupted write statement makes SQLite roll back, and the answer is aborted; an interrupted read leaves the transaction open | 30 seconds; timeout_ms lowers it |
| Write transaction idle limit, from the end of one response to the arrival of the next request; the transaction is rolled back and the channel aborted, checked every second | 30 seconds |
Write transaction lifetime, from the begin’s acceptance. An idle transaction is aborted, a running statement is interrupted and recorded timeout with the transaction aborted, and a running commit before its commit point fails with timeout | 5 minutes |
No timer acts on a commit past its commit point: a commit in its upload when its lifetime passes completes, and its answer is the commit. While a transaction is open the channel idle limit does not run.
The engine tells the server through the connection when it ends an open transaction on its own, as maintenance rolls one back; the server then releases the write lock and aborts the channel without waiting for its next request. A statement or commit that maintenance interrupts records maintenance, and its transaction is aborted or, for a commit, ended.
Batch and describe
A batch is one statement run once per parameter set, sql with param_sets, all arrays or all objects, or several statements, statements, each with sql and optionally params or named: 1 to 10,000 entries. An entry runs under the SQL policy like any statement, and must return no columns; transaction control in it is refused as in an execute. Its answer is one results frame per 1,024 entries, each entry’s rows_affected and last_insert_rowid, then done with entries, the sum of rows_affected and the last last_insert_rowid. The first entry that fails stops it, and its error carries batch_index, counted from 0; a statement of param_sets that does not compile fails at entry 0.
- With no transaction open, a batch is an autocommit write: it takes the write lock and a fresh connection, runs every entry inside one
BEGIN IMMEDIATEandCOMMIT, and is one commit, carrying the commit identifier of its own sequence number. Itsresultsframes are held like a write’s rows until the commit has an outcome. A batch that fails leaves nothing and sends noresultsframe. - Inside a transaction it runs on the transaction’s connection. The entries before a failed one keep their effects and their
resultsframes are sent; the error hasnot_executed: false, as for anexecute.
Replay keeps a batch’s results frames within the 64 KiB of retained data; a batch with more is replayed with data_omitted: true.
A describe answers a columns frame, params frames and done with param_count and txn, without running the statement: with no transaction open, on a pooled connection, as the stateless describe does, and txn is the leader’s head; inside a transaction, on its connection, so that it sees the transaction’s own schema changes, and txn is the transaction’s snapshot. SAVEPOINT, RELEASE and ROLLBACK TO can be described inside a transaction only; other transaction control is invalid_request. A describe that fails records its error with not_executed: true, inside a transaction too, and leaves the transaction open.
Read-only channels
An open with {"mode":"read_only"} needs the read role, and every request on the channel needs read only. The pod that serves the open owns the channel. On the leader, min_txn above the leader’s head is 503 behind. A standby with peer set and a fresh follower (follower_reads on) serves the open itself, once its peer record is written, when its follower reaches min_txn within the catch-up limit, 500 ms, and the principal has room for a read-only transaction and a channel there; the open’s txn is the follower’s snapshot. Otherwise the standby forwards the open to the leader, which then owns the channel. Without peer, a standby answers a read-only open not_serving. Other pods reach a follower’s channel through its pod’s peer record (Forwarding between pods). The token is r1.<instance>.<database id>.<open head>.<secret>, and the channel counts against the same channel bounds as write channels. The open answer has no epoch.
A read-only channel takes the same sequenced requests, cancel and close as a write channel, but never takes the write lock and never commits. Its connection refuses writes with PRAGMA query_only, so a write fails with sql_error carrying SQLite’s SQLITE_READONLY, code 8.
executeandbatchwith no transaction open run in a read of their own on a pooled connection:BEGIN, the snapshot, the statement,ROLLBACK. Rows stream as they are read, andtxnis the snapshot. The connection takes writes again before it goes back to the pool, and is closed if it cannot.beginstarts a read on a pooled connection, and reports its snapshot astxn, taken in the same step, and runs the first statement inexecute, if any. The transaction then holds that connection until it ends, and every statement in it reads that snapshot, whatever commits after; itstxnis the snapshot. Read-only transactions hold at most half the pod’s connections and all but one of a principal’s quota, so that writes, which hold the write lock while they wait for a connection, and the principal’s own stateless requests find the rest turning over. On a small memory budget there may be none to keep back: a principal whose quota is 1 (a pod of fewer than 8 connections) may still hold one read-only transaction, and until it ends that principal’s other requests that need a connection getoverloaded; on a pod of 1 connection that holds for every principal.commitends the transaction and answerscommitted: true,wrote: falseand the snapshot astxn;rollbackends it and answers the leader’s head, or on a follower its latest snapshot. Either closes the connection.describeandpinganswer as on a write channel.
| Limit | Value |
|---|---|
| Read-only transaction idle limit, from the end of one response to the arrival of the next request; the transaction is rolled back and the channel aborted, checked every second | 30 seconds |
Read-only transaction lifetime, from the begin’s acceptance; an idle transaction is aborted, and a running statement is interrupted and recorded timeout with the transaction aborted | 120 seconds |
An open read pins its snapshot in the leader’s WAL, so maintenance ends it, and the channel learns it as transaction_aborted with cause: "maintenance", as for a write transaction.
On a follower, every request that starts a read, a begin included, pins a fresh snapshot at or above min_txn before acceptance, waiting up to 500 ms; one the follower cannot reach, or any with no fresh observation, is 503 behind, not executed. The driver closes a channel that answers behind and opens another, which goes to the leader while the follower is still behind or stale. A transaction reads its pinned snapshot on a connection of its own, which counts against the same connections and read-only transaction places as on the leader, until it ends; the limits above apply. Compaction keeps what a snapshot reads for at least its grace period, 5 minutes, after a newer manifest replaces it, which is longer than a transaction’s lifetime plus the follower’s 2-second freshness bound. If compaction overtakes a snapshot anyway, the statement is recorded maintenance and an open transaction is aborted with cause: "maintenance". A follower’s channels end, and answer channel_lost, when its pod takes office, shuts down, or stops following; a leader change on other pods does not end them.
Cancel
A cancel names a channel and a sequence number, needs the read role and the channel’s principal, has a 4 KiB body limit, and takes no sequence number of its own:
| The named request | Answer |
|---|---|
| The last, finished | done with its receipt, changing nothing |
| The last, running | Interrupts it through its connection unless it is past its commit point, then answers once it has finished, with its receipt: cancelled if the interrupt came first, the commit if it did not. A commit in its upload is never interrupted |
| The next, with nothing running | Records it as cancelled before it arrived (cancelled, not_executed: true, final: true), with no body digest: every later delivery of that number gets that receipt, whatever its body, and nothing runs. An open transaction stays open |
| The next, with a request running | 409 channel_busy |
| Lower, or higher than the next | 409 stale_sequence or sequence_gap |
| Any but the last, on a closing channel | 410 channel_lost |
A cancel that joins a closing channel’s wait answers with the same receipt and txn_state: "none".
Receipts and replay
Each channel keeps the receipt of its last request: its terminal frame, with an error’s own request id. A resend of that request with an identical body gets the frames its response had before the terminal one, if they were kept, then the receipt. They are kept only for a success, up to 64 KiB, and while the server’s and the database’s retained data, 32 MiB each, within the channels’ share of the memory budget, have room; otherwise the replay is the receipt alone, with data_omitted: true when the response had frames. Kept data is released when the channel accepts its next request or ends. A recorded error keeps at most 1,024 bytes of its message, the error message bound.
Closing and ending
A close needs the read role and the channel’s principal. A channel with nothing running ends at once, and an open transaction is rolled back before the answer. One with a request running becomes closing: the request is interrupted through its connection, which before its commit point records cancelled, and the close is answered once the request has finished, its outcome is recorded, and an open transaction is rolled back and the write lock released, so a close never answers before a running commit’s outcome. A second close, or a cancel of the running request, joins the first and answers after that too. The answer carries last_seq and that request’s receipt.
A channel also ends when it has been idle for 10 minutes (the channel idle limit, checked every second; idle time runs from the end of one request to the arrival of the next, a replay or a refusal included, and never while a request runs or a transaction is open), and when its leader stops or leaves office, which rolls back an open transaction. A request that runs when the leader stops keeps its channel in the table, ended but unsettled, until it has finished. Every request on an ended channel gets channel_lost.
Resolve
A resolve settles a write whose channel was lost. It names a channel and a sequence number, needs the write role, has a 4 KiB body limit, changes nothing and records nothing. Any pod takes it and forwards it to the leader, which answers with the commit identifier of that token and number:
| The leader finds | Answer |
|---|---|
| It has stopped serving the database | unknown |
| The token’s open head above its head: it has been deposed without knowing it yet | 503 behind; send it again |
| The open head more than the resolve bound, 100,000 transactions, below its head | unknown |
| A commit above the open head carrying the identifier | committed, with that commit as txn |
| Otherwise, an epoch bump above the open head | not_committed |
| Otherwise, the channel live in its table, closing or ended but unsettled included, under any principal | pending |
| Otherwise | not_committed |
Every answer but committed carries the leader’s head as txn. A token that names another database, or whose open head is not a number, is 400 invalid_request. A write that changed nothing created no commit, so once its channel has ended it is not_committed, which is exact: it has no effect.
The leader answers from one observation: it reads its channel table, then the engine’s index of commit headers and its head in one step, then checks that it still serves. The engine’s index holds the headers above the manifest the leader took office on and of every commit since, and drops those more than 65,536 numbers below the head once a compaction has passed them. When the range from the open head to the head reaches below the index, the resolve reads the missing headers from storage, newest first, at most 16 at a time per database and 64 per server, each once: the leader keeps those it read for later resolves, and a resolve waits for a header another is reading. One resolve per principal and database reads from storage at a time, and one resolve starts at most 4,096 header reads, then answers unknown; sent again, it continues from the headers already read. A read runs within the statement time, 30 seconds, on its own, so a client that goes away does not fail it for others. A read that fails is tried again until the request’s statement time ends, and the answer is then unknown; a header missing or corrupt in storage is unknown at once. A header below the head never changes, retired or not, so a header read from storage is as good as one in the index.
Maintenance, the tail bound and a stopping leader
While the leader is in maintenance, a query or describe gets 503 maintenance, and a running one ends with maintenance as its terminal frame. The leader compacts the database’s log in the background. When the log still reaches the engine’s tail bound, 32,768 commits above the manifest, the engine refuses reads and writes until a compaction clears it: a query then gets maintenance with a message that names the bound and asks for a retry, and the server stays ready. If the leader cannot compact, because the new manifest would pass its size limit, the refusal lasts: the message says the leader cannot compact, and the server reports itself not ready for as long as it leads that database. A query running when the leader stops, on shutdown, step-down or fail-stop, is interrupted and ends with not_serving. A write interrupted that way gets channel_lost (see Write channels). At the tail bound, a write refused before acceptance gets maintenance without naming the bound: the engine refuses its fresh connection as it does in any maintenance.
Readiness
With probe_listen set, the server answers GET /readyz on that address, in plain HTTP and without authentication: 200 while it leads at least one configured database or has a fresh follower for one. A led database at a tail bound it cannot compact past vetoes readiness across the pod. The probe answers 503 when neither a leader nor a fresh follower is available, during a tail-bound veto, and from the start of shutdown. A server whose databases do not exist yet is not ready, so a Service that sends traffic only to ready pods never delivers the first PUT. Send it through a second Kubernetes Service over the same pods with publishNotReadyAddresses: true, or through kubectl port-forward to one pod.
Known limits of readiness in this version:
- Readiness is per pod, not per database. One database at a tail bound its leader cannot compact past makes the pod not ready for every database it leads.
- Each database’s office loop runs on its own, so the databases of a set of pods can be led by different pods, and readiness cannot steer a request to the pod that leads its database. With
peerset, the others forward it; without it, they answernot_serving, so list each database on one set of active pods, or run one active pod.
Forwarding between pods
With peer set, any pod that lists a database accepts any request for it. A pod that cannot serve a request itself forwards it once to the pod that can, over a second listener with mutual TLS. A client never gets a redirect.
| Request on a pod that does not lead the database | Goes to |
|---|---|
query, describe | A fresh local follower, if follower_reads is on; otherwise, or when the follower answers not_serving or behind before its answer starts, the leader |
A write open, resolve | The leader |
| A read-only open | This pod’s follower, with follower_reads on and its peer record written, if it reaches min_txn within 500 ms and the principal has room for a read-only transaction and a channel; otherwise the leader |
channel, channel/cancel, channel/close | The pod whose process the token names: the leader for a write channel; for a read-only channel, the pod in that process’s peer record if it has one, otherwise the leader |
PUT, GET status | Served where it arrives; status is 503 not_serving on a pod that does not lead |
A pod that leads the database serves every request itself, except a channel request, cancel or close whose token names another process: it is forwarded as on any other pod, so that a leader deposed without noticing yet, for up to a lease renewal period, sends it to the leader in office rather than answering channel_lost.
Membership. Once its office loop reports it in office, a leader writes a leader record at <prefix>/<db>/leader with its process identifier (the one its channel tokens name), the host:port of its peer listener, the database identifier, its epoch and the transaction number of its epoch bump. It replaces only a record of an epoch no higher than its own, and retries a failed write every second. On step-down or shutdown it removes the address with a conditional replace, so it never overwrites a later leader’s record. A forwarding pod reads the record for each request it forwards. With follower reads on, each pod also writes a peer record at <prefix>/_peers/<instance> when it starts, with its process identifier and the host:port of its peer listener, and deletes it on a clean shutdown; a read-only channel request whose token names a process with such a record goes to that address. Nothing beyond object storage and the configuration is needed.
The hop. The forwarding pod authenticates and authorises the request as usual, reads and checks the whole body, then sends the same method, path, body bytes, end-to-end headers and Authorization to the peer listener, with Skylite-Forwarded: 1 (peer for a hop by peer record), Skylite-Request-Id (its own request id, which the answer carries) and Skylite-Budget-Ms: what is left of the statement time, 30 seconds or timeout_ms if lower, after the time already spent. Hop-by-hop headers are dropped. The receiving pod verifies the bearer token and the role again, lowers its statement time to the budget, and never forwards the request again: if it cannot serve it, it answers 503 not_serving. The answer is relayed as it arrives, frame by frame, with its status and headers. If the other pod’s answer is cut after it started, the forwarding pod cuts its own (HTTP/1.1 closes the connection, HTTP/2 resets the stream) and adds no terminal frame. It waits for the other pod at most the budget plus 30 seconds.
One attempt. A forwarding pod sends a request at most once. Only a POST with a body is forwarded: Go’s HTTP client resends a GET or a request without a body by itself after some connection failures, and does not resend a body it cannot rewind. When the hop fails the forwarding pod answers itself:
| Failure | Answer |
|---|---|
| No leader is recorded, or the record has no address | 503 no_leader, or owner_unreachable for a channel request, cancel or close; not_executed: true |
| The hop failed before a connection to the other pod was obtained, such as a refused connection or a failed TLS handshake | The same, not_executed: true |
The hop failed after a connection to the other pod was obtained, or the answer had no Skylite-Protocol marker | The same with not_executed: false: the other pod may have accepted the request, so its outcome is unsettled. The line is the connection, not the request headers, because Go’s HTTP/2 transport can send the headers before it reports them written |
| The token names this pod’s own process, which neither leads the database nor owns read-only channels on a follower | 410 channel_lost, not_executed: true |
| The token names another process than the record, the record is of the same database, its bump is above the token’s open head, and the token is not a read-only one whose process has a peer record | 410 channel_lost, not_executed: true: the channel opened under an earlier office, which has ended |
| The token names another process than the record otherwise | 503 owner_unreachable, not_executed: true |
| A read-only token names a process with a peer record, and the hop to its address fails before a connection is obtained, or reaches a pod that does not hold the channel | 410 channel_lost, not_executed: true: the channel’s process is gone or no longer serves it |
| A read-only token names a process whose peer record cannot be read | 503 owner_unreachable, not_executed: true |
Pod authentication. The peer listener requires TLS 1.3 and a client certificate that chains to peer.ca_file. A forwarding pod requires a server certificate that chains to the same CA and carries peer.server_name. Every pod presents its one peer certificate as both server and client, so the certificate needs both the serverAuth and clientAuth extended key usages. Use a CA that issues peer certificates and nothing else: whoever holds a certificate it issued is a pod. Forwarded requests go only to the address in the leader record or, for a read-only channel, in its process’s peer record, and through no HTTP proxy. The pod-to-pod headers are accepted only on the peer listener: a client that sends Skylite-Forwarded or Skylite-Budget-Ms gets 400 invalid_request, and a Skylite-Request-Id it sends is ignored.
Configuration
The configuration is one JSON file. Unknown fields are refused, and the server does not start with a configuration it refuses. The file holds no secret.
{
"listen": ":8443",
"tls": {"cert_file": "/etc/skylite/tls.crt", "key_file": "/etc/skylite/tls.key"},
"auth": {
"issuers": [
{"issuer": "https://kubernetes.default.svc.cluster.local", "audience": "skylite", "jwks_file": "/etc/skylite/jwks.json"}
],
"rules": [
{"issuer": "https://kubernetes.default.svc.cluster.local", "subject": "system:serviceaccount:ops:provisioner", "database": "*", "role": "admin"}
]
},
"storage": {
"prefix": "skylite",
"s3": {"bucket": "my-bucket", "region": "eu-west-1"}
},
"databases": ["orders"],
"peer": {
"listen": ":8444", "address_env": "SKYLITE_PEER_ADDRESS",
"cert_file": "/etc/skylite/peer.crt", "key_file": "/etc/skylite/peer.key",
"ca_file": "/etc/skylite/peer-ca.crt", "server_name": "skylite-peer"
},
"probe_listen": ":8081"
}
| Field | Meaning |
|---|---|
listen | TCP address to listen on. Required |
tls.cert_file, tls.key_file | PEM certificate chain and key. The server serves HTTP/1.1 and HTTP/2 over TLS 1.2 or later. They are read once, at start |
plaintext | true serves HTTP/1.1 and HTTP/2 without TLS (prior-knowledge h2c), for a server behind a mesh or proxy that terminates TLS. Exactly one of tls and plaintext must be set |
auth.issuers[] | issuer (the exact iss value), audience (a value aud must contain) and, optionally, jwks_file, a JSON Web Key Set file read instead of OIDC discovery. The server reads each jwks_file at start and does not start if one is missing, unreadable or holds no usable key; it reads it again once its keys are an hour old, and when a token names a key id it does not hold, at most once a minute, so a rotated file is picked up without a restart. Without jwks_file, issuer must be an https URL. Token and key rules are in the configuration reference |
auth.rules[] | issuer; exactly one of subject or claim with value; database, a name or a pattern with * and ?; role, one of read, write, admin. Without a matching rule, access is denied |
storage.prefix | Key prefix, segments separated by /. A database’s objects live under <prefix>/<db>/, and the pods’ peer records under <prefix>/_peers/. Empty means no prefix |
storage.localfs.path | A local directory. For trying the server out; a pod’s local disk is not durable |
storage.s3 | bucket and region (required), endpoint for an S3-compatible service, path_style to address the bucket in the path |
storage.gcs | bucket (required) and endpoint for an emulator, which then gets no credentials |
storage.azure | account and container (required), endpoint for Azurite or another blob account URL (empty means https://<account>.blob.core.windows.net), and exactly one of shared_key_file (path to a file holding the base64 shared key), shared_key_env (name of an environment variable holding it) and entra: true (an Entra ID token from azidentity’s default credential chain) |
databases | The databases this server leads and answers queries on: names of the {db} form, each once, at most one fewer than the SQLite connections the memory budget holds, 13 at 2 GiB. Optional; without it the server serves PUT alone. The leaders’ local files go in a directory under the system’s temporary directory (TMPDIR), removed on shutdown |
follower_reads | Serve stateless reads from a fresh local follower while in standby. Optional, defaults to true when peer is set and to false otherwise |
peer.listen | TCP address of the peer listener for forwarded requests. Without peer, nothing is forwarded |
peer.address_env | Name of an environment variable holding the host:port other pods dial to reach this pod’s peer listener, for example set to $(POD_IP):8444 from the downward API. The server does not start if it is unset or holds no host |
peer.cert_file, peer.key_file | PEM certificate and key this pod presents as peer server and client, read once at start |
peer.ca_file | PEM certificates of the CA that issues peer certificates, and nothing else |
peer.server_name | The DNS name every peer certificate carries, checked on the pod a request is forwarded to |
probe_listen | TCP address of the readiness probe. Optional |
memory_budget | The memory budget in bytes, from 384 MiB to 64 GiB, in place of three quarters of the memory limit. Optional |
An endpoint must be an http or https URL with a host and no user information, query string or fragment, so that it carries no credential; the server does not start with one that breaks this, and the error does not repeat the value.
storage holds exactly one of localfs, s3, gcs and azure. The storage backends page says how each one has been tested. S3 credentials come from the AWS SDK’s default chain (environment variables, shared files, web identity, the instance or task role), Google Cloud Storage credentials from Application Default Credentials, and Azure Blob Storage either reads an account shared key from the file named by shared_key_file or the environment variable named by shared_key_env, or, with entra: true, uses azidentity’s DefaultAzureCredential (a service principal in AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET, workload identity, a managed identity, then the Azure CLI, Azure Developer CLI and Azure PowerShell logins; AZURE_TOKEN_CREDENTIALS narrows it).
Logs and shutdown
The server writes JSON log lines to standard error: one when it starts; one per refused request with its request id and code; one for each authentication or authorisation refusal with these fields: the reason, the configured issuer, the subject once the signature has verified, the key id and the first 12 hex digits of the token’s SHA-256 hash, and for a 403 the database and the role it needed; one for each created database with the principal’s issuer and subject; the office loop’s lines, with the database’s name, when it takes office, steps down or fails a candidacy; one for each query or write that fails with internal, ends with an unknown outcome or fails after committing, with the engine’s class of the failure; and one for each failed forward, saying whether its request may have been sent, and for each leader record the server could not read, write or withdraw. Logs never hold a bearer token or part of one, a channel token, SQL text, parameters or SQLite’s messages.
On SIGTERM or SIGINT the server reports itself not ready, stops accepting connections, waits for running requests (a create, a query or a write runs for at most 30 seconds before its commit point, and the wait is at most a minute), leaves office, releasing each lease, then exits with status 0. If requests are still running after a minute, it closes their connections and exits with status 1. A second SIGTERM or SIGINT during the wait ends the process at once.
Try it locally
A JWKS file and a token from your own issuer, or from a test signer, are enough:
cat > skylite.json <<'EOF'
{
"listen": "127.0.0.1:8080",
"plaintext": true,
"auth": {
"issuers": [{"issuer": "https://issuer.example", "audience": "skylite", "jwks_file": "jwks.json"}],
"rules": [{"issuer": "https://issuer.example", "subject": "me", "database": "*", "role": "admin"}]
},
"storage": {"localfs": {"path": "data"}},
"databases": ["orders"]
}
EOF
mkdir -p data
skylite serve -config skylite.json &
curl -i -X PUT -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
--data '{}' http://127.0.0.1:8080/v1/databases/orders
curl -i -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
--data '{"sql":"SELECT 1 + ? AS two","params":[1]}' http://127.0.0.1:8080/v1/databases/orders/query
The query answers 503 not_serving until the server has taken office for the new database. Its office loop retries a candidacy that fails, as one does while the database does not exist, with a backoff that doubles up to a third of lease_ttl, so that can take about 20 seconds after the PUT at the default. A new database has no tables. To write, open a channel and send each statement with the next sequence number:
curl -s -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
--data '{"mode":"write"}' http://127.0.0.1:8080/v1/databases/orders/channels
# take "token" from the answer's channel object
curl -s -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
--data '{"channel":"'"$CHANNEL"'","seq":1,"op":"execute","sql":"CREATE TABLE t (a)"}' \
http://127.0.0.1:8080/v1/databases/orders/channel
Not built yet, and not verified
- Parts of the memory budget: HTTP connections and response frames up to 1 MiB are not charged to it, by design, and the 1,024-connection bound is the only bound on connections. A frame larger than 1 MiB is charged only once it is encoded, and frames waiting for room are not ordered among themselves. The 32 MiB reserved per database for resolve’s headers is sized from one measurement, not checked by a test. The cgroup is read at
/sys/fs/cgroup, which is the container’s own inside a cgroup namespace. - Read-only channels on followers: a peer record left by a pod that crashed is never removed, and the page index an open transaction’s snapshot keeps on a follower is not charged to the memory budget. A channel that fell back to the leader stays there.
- The leader’s window of recent commit headers, which a resolve searches, is the engine’s index and is not filled in the background after a takeover (Resolve).
- Forwarding to the leader a
queryordescribea follower cannot compile, as after a schema change the follower has not applied yet: the follower answers the compile error. The leader record is read from storage for every forwarded request. - Forwarding is tested between servers in one process on one local store, over loopback TLS, not between pods or through a mesh.
database_not_foundfor a query: a server that does not lead the database and has no enabled follower for it answersnot_serving, whether or not it exists.- Keepalive frames during a long query or a write’s lock wait, and the compiled-statement cache: every query and write compiles its statement.
- The commit point, where the commit’s object is created in storage, is not visible to the server, so a close or a cancel cannot tell a write or commit before it from one in its upload; it interrupts the connection, and the engine reports what happened.
- Maintenance starts only from a commit or a write of the writer that holds the write lock, so it never meets another channel’s idle open transaction in this version; the server’s handling of the engine ending an idle transaction is tested by closing its engine connection, not by maintenance.
- A tail bound the leader cannot compact past is noticed when a request meets it, so a server that takes office there reports itself ready until its first query.
- The header block deadline on HTTP/2 streams: there, only the idle timeout bounds a header block that never ends. The 431 answer is tested on HTTP/1.1 only.
- Reloading a rotated TLS certificate without a restart.
- Running on a Kubernetes cluster, or behind a real mesh or ingress, has not been tested.