Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions USING-HYDRADB.md
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,18 @@ no meaning across scans.
empty page to fetch.

**A drained or dead cursor fails with yet another message**:
`result cursor is unknown or expired`. You will see it if you keep a cursor
`result cursor is unknown or expired on this node`. You will see it if you keep a cursor
after its scan completed — including when a dropped `page_size` silently drained
the scan in one response (see below).

**A cursor lives on one node.** The remaining rows are held in the memory of
the node that served page one, so every later page must reach that node. With
more than one node, a load balancer that spreads requests sends some pages
elsewhere, and they fail with the same `unknown or expired on this node` error.
In the Helm chart, set `service.https.sessionAffinity: ClientIP` when the proxy
is off, or `proxy.readRouting: owner` when it is on. Running queries work the
same way: a cancel must reach the node that runs the query.

Paged reads stay pinned to one storage snapshot, so rows do not shift underneath
a long pagination.

Expand Down Expand Up @@ -950,7 +958,9 @@ may mean a budget was hit, not that the data is missing.**
`POST /v1/graphs/{graph_id}/queries/{query_id}/cancel`, using the `query_id`
from the response. It only affects a query that is still running; against a
finished or unknown id it returns **400** with
`no active query with id … was cancelled`.
`no active query with id … was cancelled on this node`. The cancel must reach
the node that runs the query; see [Pagination](#pagination) for the chart
settings that keep a client on one node.

## Transactions

Expand Down
11 changes: 11 additions & 0 deletions charts/hydradb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ storage. Query nodes discover generations asynchronously and never perform a
full topology build on a request thread. Scale `node.replicaCount` for query
capacity and `indexer.replicaCount` for background indexing capacity.

HTTP result cursors and running queries are held in the memory of the node that
served the first request, so the next page of a paged result and a cancel must
reach that same node. With `node.replicaCount` above 1:

- Proxy off: set `service.https.sessionAffinity: ClientIP` so the `-https`
Service keeps each client on one node. Clients behind one NAT or ingress
share a node.
- Proxy on: the default `proxy.readRouting: fleet` routes every page request
again. Set `proxy.readRouting: owner` if clients page HTTP results or cancel
reads.

## Image Publication

`.github/workflows/container.yml` builds the production Dockerfile on pull
Expand Down
6 changes: 6 additions & 0 deletions charts/hydradb/templates/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ spec:
- name: https
port: {{ .Values.service.https.port }}
targetPort: https
{{- if eq (.Values.service.https.sessionAffinity | default "None") "ClientIP" }}
sessionAffinity: ClientIP
sessionAffinityConfig:
clientIP:
timeoutSeconds: {{ .Values.service.https.sessionAffinityTimeoutSeconds | default 10800 }}
{{- end }}
{{- with .Values.service.https.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- toYaml . | nindent 4 }}
Expand Down
12 changes: 11 additions & 1 deletion charts/hydradb/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,17 @@
"properties": {
"advertisedBoltAddress": { "type": "string" },
"bolt": { "$ref": "#/definitions/service" },
"https": { "$ref": "#/definitions/service" },
"https": {
"allOf": [
{ "$ref": "#/definitions/service" },
{
"properties": {
"sessionAffinity": { "enum": ["None", "ClientIP"] },
"sessionAffinityTimeoutSeconds": { "type": "integer", "minimum": 1, "maximum": 86400 }
}
}
]
},
"adminPort": { "type": "integer", "minimum": 1, "maximum": 65535 }
}
},
Expand Down
12 changes: 12 additions & 0 deletions charts/hydradb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ service:
port: 443
annotations: {}
loadBalancerSourceRanges: []
# HTTP result cursors and running queries are held in the memory of the
# node that served the first request. With node.replicaCount > 1 and the
# proxy off, set ClientIP so a client's next page and its cancel reach that
# node. ClientIP keys on the source address this Service sees, so clients
# behind one NAT or ingress share a node. Behind the proxy this Service is
# not on the client path; see proxy.readRouting.
sessionAffinity: None
# Used only with ClientIP. 10800 (3 hours) is the Kubernetes default.
sessionAffinityTimeoutSeconds: 10800
adminPort: 9090

runtime:
Expand Down Expand Up @@ -279,6 +288,9 @@ proxy:
pullPolicy: IfNotPresent
# The env's read policy, the same knob graph-node reads. Behind the proxy the
# nodes' own setting does nothing, since the proxy answers ROUTE.
# Under fleet, each HTTP page request is routed again, so the next page or a
# cancel can reach a node that does not hold the cursor or the query. Use
# owner if clients page HTTP results or cancel reads.
readRouting: fleet
# Concurrent units per graph-node across all proxy replicas; each replica
# holds nodeBudget / replicas.
Expand Down
9 changes: 7 additions & 2 deletions src/client/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2493,7 +2493,9 @@ impl ClientQueryService {
return Err(GraphError::UnsupportedQuery {
reason: QueryFailureReason::InvalidRequest,
dialect: "ClientProtocol",
feature: "result cursor is unknown or expired".to_string(),
feature: "result cursor is unknown or expired on this node; a cursor lives only on the node that \
served the first page, so send every page of a scan to that node"
.to_string(),
});
};
if cursor.owner != expected_owner
Expand Down Expand Up @@ -2591,7 +2593,10 @@ impl ClientQueryService {
return Err(GraphError::UnsupportedQuery {
reason: QueryFailureReason::InvalidRequest,
dialect: "ClientProtocol",
feature: format!("no active query with id {query_id} was cancelled"),
feature: format!(
"no active query with id {query_id} was cancelled on this node; a query can only be \
cancelled on the node that runs it"
),
});
};
active.cancellation_token.cancel();
Expand Down
Loading