Skip to content

Troubleshooting

Common failure modes and recovery procedures for the Virtufin API Gateway.

See also: Development guide → Troubleshooting for service-startup, port-conflict, and protoc-generation issues. Deployment guide → Troubleshooting for Kubernetes pod, Dapr sidecar, and image-pull issues.

Operation-level failures

These failures occur after the service is running, typically surfacing as gRPC status codes or HTTP 5xx responses.

UNAVAILABLE from a backend service call

Symptom: Invoke or ListMethods returns StatusCode.Unavailable for a specific backend service.

Likely causes: - The backend service (WorkManager) is not running, or is on the wrong port - The services.json config has the wrong host:port for the backend - The Dapr sidecar is not running alongside the backend (no daprd container in docker ps, no dapr_runtime_* log lines) - The backend is in another namespace/pod and DNS resolution is failing

Diagnose:

# 1. Verify the backend is listening
grpcurl -plaintext <backend-host>:<grpc-port> list

# 2. Check Dapr sidecar logs
docker logs <backend-pod> -c daprd | tail -50

# 3. Check the API Gateway logs for the call stack
kubectl logs -n virtufin -l app=api | grep -i "<service-name>"

# 4. Verify the services.json config matches
cat config/services.json | jq '.services[] | select(.name=="<service-name>")'

INVALID_ARGUMENT on Subscribe

Symptom: The Subscribe RPC returns immediately with StatusCode.InvalidArgument and the message "At least one filter must be set".

Likely cause: The request has empty services, topics, and eventTypes arrays. The filter validation requires at least one non-empty filter.

Fix: Set at least one of services, topics, or eventTypes to a non-empty value.

RESOURCE_EXHAUSTED on SaveState

Symptom: SaveState returns StatusCode.ResourceExhausted with a message about state-store capacity.

Likely cause: The Dapr state store (Redis/Valkey) is full. The default maxmemory-policy in redis.conf is noeviction, so writes fail when memory is exhausted.

Fix: Increase the Redis instance size, or set maxmemory-policy allkeys-lru to evict older keys.

DEADLINE_EXCEEDED on Invoke

Symptom: Invoke returns DeadlineExceeded after the configured timeout.

Likely cause: The backend method itself is slow (not the network). Invoke has a 30-second default timeout inherited from the gRPC client. The underlying backend may be doing expensive work (e.g., loading a large Python worker code module).

Fix: Increase the per-RPC timeout (configurable via Grpc:DefaultTimeoutSeconds in appsettings.json) or optimize the backend operation.

State store failures

A write fails with INTERNAL

Symptom: SaveState, DeleteState or DeleteBulkState fails with INTERNAL and the message "An internal error occurred".

Cause: the state store refused the write. The message is deliberately generic; the ErrorInfo names the key (resource) and the real cause is in the API's server logs. Every write failure is a non-OK status (Errors), so a returned write always landed.

grpcurl -plaintext -d '{"service":"workmanager","key":"workmanager.worker.abc","value":"{\"n\":1}"}' \
  localhost:5002 virtufin.State/SaveState

Reading another service's keys succeeds unexpectedly

Symptom: GetState(service: "statestore", key: "sys.workmanager.worker.x") returns data instead of failing.

Cause: This is expected. service selects the Dapr state store; it is not a namespace check. Keys are not scoped to the calling service. See security.md.

QueryState fails for every query, including {}

Symptom: All QueryState calls return Internal, even Dapr's match-everything query.

Likely cause: The configured store's Dapr component does not implement the Query API. For Redis/Valkey this needs the RediSearch module loaded and queryIndexes metadata declared on the component.

Fix: add the metadata and RediSearch module, or use GetBulkState against known keys.

Pub/Sub failures

Subscriptions stop receiving events

Symptom: A client subscribed via the Pubsub.Subscribe RPC stops receiving events after a few minutes.

Likely cause: either a dropped stream or a consumer that fell behind.

A subscriber that is behind is not dropped and holds nobody back: each subscriber buffers up to 1024 events, and when the buffer is full the gateway serves it from the topic's stream at its own pace. The call ends only when that is not possible. Check the status the call ended with:

Status Cause Fix
DATA_LOSS The consumer was behind further than the stream reaches back (streamTTL, 1 minute by default). Make the consumer faster (take batches, move slow work off the read loop); if its source can wait, publish paced (Paced publishing); subscribe again.
RESOURCE_EXHAUSTED The consumer took no event for PubsubSubscriberStallSeconds (default 300), or the pub/sub backend has no stream the gateway can read (Redis and NATS JetStream have one; JetStream needs PubsubNatsUrl). Find out why the read loop stopped; subscribe again, with replay_since for what the stream still holds.

Otherwise check the client side: a dropped gRPC stream (idle timeout on an intermediary, pod restart, CancellationToken fired) ends the Subscribe call, and the server's finally releases both the in-process subscriber and the shared Dapr subscription. The stream does not resume itself — the client must reconnect.

Diagnose:

# Check the sweeper logs
kubectl logs -n virtufin -l app=api | grep -i "sweeper\|heartbeat"

# Check the subscription count
curl http://localhost:5001/health

Fix: Restart the client subscription; the next sweep will recreate the health record.

RESOURCE_EXHAUSTED on a paced PublishEvents

Symptom: A PublishEvents call with pace set ends with RESOURCE_EXHAUSTED after about a minute.

Cause: A consumer of one of the call's topics was behind by PubsubPaceHighWaterSeconds or more for the whole of PubsubPaceMaxWaitSeconds. The status names that consumer and its lag. Nothing of the call was published.

Fix: 1. Find out why that consumer is slow: its worker's logs, and its pod's CPU. 2. Publish the call again, paced. 3. If losing events past retention is acceptable for this run, publish it without pace instead.

Recovery procedures

Restart the gateway after a state-store outage

If the Dapr state store is unavailable for an extended period, the gateway may have cached stale state. Restart all gateway replicas to force a fresh ServicesConfigurationLoader.LoadAsync and rebuild the gRPC channel pool:

kubectl rollout restart deployment/api -n virtufin
kubectl rollout status deployment/api -n virtufin

Reset all in-flight subscriptions

If subscriptions are wedged (heartbeat lag, broken state), force a clean state:

# Restart all gateway replicas (closes all subscriptions)
kubectl rollout restart deployment/api -n virtufin

# Wait for old replicas to terminate
kubectl rollout status deployment/api -n virtufin

# Clients must re-subscribe

Reporting issues

If none of the above resolves your issue, gather the following and file a Gitea issue:

  • API Gateway version (LIBRARY_VERSION from the build info endpoint)
  • services.json config (redact any sensitive values)
  • Full error message and gRPC status code
  • Relevant log lines from the gateway and the affected backend service