HTTP cursors, backpressure and recovery
Bounded queues, acknowledged sequences, expiration, structured errors and uncertain outcomes.
Stream lifecycle
A cursor connects SQL production to network consumption. Bounded queues propagate consumer backpressure to the producer. Sequenced protocols can replay the last retained packet; requesting the next implicitly acknowledges the previous one. Fetch recovery retains the same sequence, whereas submitting query again creates a new execution with its own effects.
Default limits and server configuration
| Environment variable | Default | Accepted range |
|---|---|---|
| OCTAVIIUS_API_MAX_BATCH_ROWS | 65536 | 1..1048576 |
| OCTAVIIUS_API_BATCH_BYTES | 1048576 | 1024..16777216, <= MAX_BATCH_BYTES |
| OCTAVIIUS_API_MAX_BATCH_BYTES | 8388608 | 1024..67108864 |
| OCTAVIIUS_API_MAX_ROW_BYTES | 16777216 | 1024..67108864 |
| OCTAVIIUS_API_CURSOR_TTL | 300 seconds | 1..86400 |
| OCTAVIIUS_API_MAX_CURSORS | 64 | 1..1024 |
| OCTAVIIUS_API_MAX_USER_CURSORS | 8 | 1..128 |
Variables are read at Core startup. Read effective capabilities instead of assuming defaults. batch_rows defaults to 500; 8192 and 32768 are possible within limits. batch_bytes targets serialized row data, not the complete HTTP envelope or total process memory. Incoming HTTP bodies remain limited to 2 MiB.
Bounded memory, large cells and snapshots
Producer queues are bounded: slow clients eventually apply backpressure. A simple scan can return before reading the entire table; sorting, joins and aggregation may require earlier work and temporary files. Streaming transport does not mean every SQL operator avoids materialization.
A row larger than the packet target can be sent alone below the absolute serialized-row limit. Larger rows fail explicitly with ROW_TOO_LARGE; they are not silently truncated. A SELECT pins snapshot roots while producing results; concurrent writes do not change that result. Two SELECTs in a script do not share a transaction-level snapshot.
Bounded replay and uncertain results
With protocols 3/4, repeat the same sequence only when a fetch response was lost. Only one packet is replayable; legacy protocol 2 offers no such recovery. Do not increment on pending. Close cursors even after their final packet to release quota.
A lost initial query response cannot be durably recovered through query_id. Do not blindly resend SQL, especially writes, scripts or procedures. Cancellation does not roll back published writes. Detected disconnects stop production; silently disappeared clients are handled through idle expiry.
Application error handling
| Situation | Typical code / SQLSTATE | Action |
|---|---|---|
| Authentication | HTTP 401 / 42501 | Check secret, expiry and revocation. |
| Permissions / Origin | ACCESS_DENIED / 42501 | Check all objects, then Host/Origin/proxy. |
| Syntax | SQL_ERROR / 42000 | Fix SQL; no automatic retry. |
| Missing / existing object | OBJECT_NOT_FOUND / 42S02; OBJECT_EXISTS / 42S01 | Check catalog/schema/object; protocol 4 refines classification. |
| Cancelled | QUERY_CANCELLED / HY008 | Report cancellation and close cursor. |
| Timeout | QUERY_TIMEOUT / HYT00 | Writes may have an uncertain outcome. |
| Expired cursor | CURSOR_EXPIRED / HY010, HTTP 410 | Close local state; explicitly decide on a new read. |
| Invalid sequence | INVALID_SEQUENCE / HY092 or HY010 | Do not skip batches. |
| Saturation | RESOURCE_LIMIT / HY001, HTTP 429 | Release resources and reduce concurrency. |
| Not implemented | UNSUPPORTED_FEATURE / HYC00 | Change approach; do not simulate a transaction. |
| Internal | INTERNAL_ERROR / HY000 | Keep identifiers and contact operations. |