SKEG · GUIDES

Write outcomes and retries

Distinguish refusals, partial completion and unknown outcomes before retrying.

Skeg 0.8 · Development documentation

Start with the reply the client received. An acknowledged write, a temporary refusal and a lost reply each need a different response.

Classify what the client observed

ObservationWhat it establishesNext step
A complete success replyThe command completed according to its contract.Record the acknowledgement. Investigate any maintenance warning separately.
A known validation or admission refusalThat operation was refused before its write was applied.Correct the request or classify whether the refusal is retryable.
A batch array containing successes and errorsEach input item has its own reported outcome.Preserve the successful items and classify each failed item.
A storage or shard-availability errorThe command could not confirm normal completion.Inspect state and logs before replaying mutations.
A timeout, disconnect or incomplete responseThe client has no complete result for the affected command or items.Treat the outcome as unknown, close the connection and reconcile.

The server can still apply a request after the client times out or closes the connection. Keep the acknowledgements you received for earlier commands.

---
config:
  flowchart:
    nodeSpacing: 25
    padding: 10
---
flowchart TD
    accTitle: Decide what to do after a write
    accDescr: Record acknowledgements, retry temporary refusals within a deadline and reconcile unknown outcomes. For other replies, follow the command contract.
    A{"Unknown outcome?"} -->|Yes| B["Reconcile"]
    A -->|No| C{"Temporary refusal?"}
    C -->|Yes| D["Retry"]
    C -->|No| E["Check contract"]

Decide whether to retry

Use the first word of the RESP error to decide whether it permits a retry. If a bracketed code is present, use it and the command contract to classify the failure. The human-readable reason can change between releases.

Code or conditionInterpretationResponse
BACKPRESSURERetryable refusal, such as a full queue or temporary memory pressure.Retry only the refused operation, with backoff, jitter, an attempt limit and an overall deadline.
RATELIMITEDA tenant backend refused admission under its rate policy.Pace requests and retry within a deadline, following that backend’s policy.
NOTDURABLEAn administrative change took effect and still needs to finish or become durable.Repeat the same administrative command as directed by the reply.
NOAUTH / WRONGPASSThe connection has not authenticated successfully.Fix the login setup or credentials before sending the command again.
CROSSSLOT for MSETThe keys span shards and the request was refused before writing.Change the operation while preserving the application’s atomicity requirement.
Invalid arguments, dimensions or coordinatesThe request cannot be applied as supplied.Correct the data or index selection.
A vector or logical disk quota errorThe tenant’s configured limit prevents the write.Free the relevant logical data or change the limit before retrying.
ERR [STORAGE]Storage failed or a shard failed to answer within its deadline.Inspect logs and affected records. Treat the outcome as unknown unless the command’s contract resolves it.

NOTDURABLE applies to SKEG.QUOTA.SET, SKEG.QOS.SET and SKEG.TENANT.DELETE. For other errors, use the operation’s contract to choose a remedy before resending. For example, BACKPRESSURE [MEMORY] permits a bounded retry. ERR [MEMORY] can mean the request can never fit and needs to be reduced.

Handle a mixed batch response

Suppose a SKEG.VMSET request for IDs 21, 22 and 23 returns these outcomes in order:

21  OK
22  BACKPRESSURE [BUSY]
23  ERR [STORAGE]

Record success for 21. Retry 22 within your deadline. Check the stored row and payload for 23 before deciding whether to write it again. If the reply was interrupted, keep only the outcomes your client could confirm and reconcile the remaining IDs. See batch ingestion.

Reconcile an unknown outcome

Keep the intended value and target tenant, key or row ID. Before resending, check whether another writer could have changed the same record. For a vector row, compare the index incarnation when you have it.

  • For KV data, read the key and compare the complete desired value.
  • For a vector row, use SKEG.VGET to read the stored float32 vector by ID. With the vget.withpayload capability, use WITHPAYLOAD to compare the vector and payload from the same read. Check independently stored document keys separately.
  • For index creation, inspect SKEG.VINDEX.INFO. Repeat creation with IFNOTEXISTS only when the requested configuration is the one you require.
  • For a batch, retain the known item outcomes and check each unresolved ID.

Approximate search is not an existence or integrity check for a specific row. It can omit an existing ID, and a matching vector alone does not establish that the document and payload are the intended revisions.

If replacing the same ID again is acceptable, resend the complete intended vector and payload under a controlled writer policy. A replacement receives a new write order; replaying an old value after a newer edit can overwrite it. The raw commands do not provide an application revision compare-and-set here.

Recognize operations whose repetition changes the result

OperationWhat repetition can do
SET with the same valueReplace a newer concurrent value with the replayed value.
VSET or a VMSET itemReplace the vector and any supplied payload, including a newer edit from another writer. A missing payload preserves the current one.
APPENDAppend the bytes again.
INCR, DECR, INCRBY, DECRBYChange the counter again.
VDEL or DELRemove a replacement that appeared after the first delete.
VINDEX.DROPRemove a new incarnation if another process recreated the name.

Stable row IDs help make a controlled import repeatable. They do not make every operation safe to replay under concurrent changes. Coordinate writers and record import/application progress outside the affected request.

Handle partial application updates

An application record can consist of a KV document, a vector and a payload. The vector and supplied payload are associated by the row write. Independent KV commands remain separate operations; there is no transaction across an arbitrary set of KV and vector commands.

Keep source content and stable identifiers so incomplete updates can be reconciled. Choose which application revision is authoritative and how readers handle a document whose text and embedding have not both been updated. Follow update and delete data for the concrete operations.

Separate acknowledgement, durability and maintenance

A success reply does not certify every future maintenance task or promise that a whole multi-command workflow is transactional. Disk persistence, process-crash recovery and surviving host power loss are different properties.

The RESP KV path requests the engine’s Kernel durability mode, which waits for an OS filesystem synchronization. Vector rows and payloads have their own WAL and staging paths. Do not infer a uniform power-loss guarantee for all of them from the shared OK reply. The vector-payload path can recover a row without its payload after a power loss; it must not attach an older payload to that replacement row.

Some work happens after a vector’s commit point. A payload-posting or cleanup failure can be recorded in logs and counters while the write still returns OK. Treat that as an operational problem to investigate, not an instruction to resubmit every acknowledged row. Filter postings can require rebuilding at the next open; leftover obsolete blobs can remain until reclamation.

Keep a backup and restore procedure, monitor maintenance, and check the result of graceful shutdown. A non-zero shutdown exit is not a retroactive rollback of earlier writes.

Reuse connections only after a complete response

A batch response can contain nested errors. The client must consume every element before issuing another command on that connection. If parsing stops inside an array, unread bytes can be mistaken for the next command’s response. Discard that connection on a decoding or framing failure.

Record the server and client versions, command name, affected IDs, outcome class and a redacted diagnostic. Do not put passwords, document bodies or raw payloads into a retry log by default.