OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug] Non-retryable provider 403 leaves SessionCommit workers busy and causes sustained high CPU

Open hua03 opened this issue 3 months ago • 6 comments

Bug Description

When a SessionCommit memory extraction calls a configured model provider and receives a non-retryable HTTP 403 error, the queue workers remain busy for a long time and the server consumes sustained high CPU. Pending SessionCommit messages continue to accumulate while several messages remain in processing.

The observed provider error was Volcengine AccountOverdueError (HTTP 403), but the issue may apply to other non-retryable provider/authentication errors as well.

Impact

  • openviking-server consumed about 135% CPU inside the container.
  • The OpenViking container remained around 142%–156% CPU, causing OrbStack's VM helper to reach about 180%–197% CPU.
  • The SessionCommit queue reached 190 pending messages and 4 in-progress messages.
  • The in-progress messages had been created hours earlier and did not complete or leave the processing state.
  • The queue count did not decrease during a 10-second observation, while CPU remained high.
  • The queue observer reported is_healthy=false, has_errors=true, and one queue error.
  • A queue worker also logged Expecting value: line 1 column 1 (char 0).

Reproduction

  1. Run OpenViking with persistent QueueFS storage and session memory extraction enabled.

  2. Configure the embedding/VLM provider so that requests return a non-retryable HTTP 403, such as an expired credential or an account/billing restriction.

  3. Submit session messages and repeated SessionCommit tasks, or allow an agent integration to do so.

  4. Observe the SessionCommit queue with:

    curl http://127.0.0.1:1933/api/v1/observer/queue
    
  5. Observe the server process CPU and the queue messages that remain in processing.

Expected Behavior

A non-retryable provider error should be classified as terminal for the current task. The worker should release its concurrency slot, mark the task as failed (or move it to a dead-letter state), and continue processing unrelated queue messages without a CPU spin or permanently stuck processing entry.

The queue status should expose the failure clearly and provide an operator-safe way to retry the task after the provider configuration is fixed.

Actual Behavior

After the provider returned HTTP 403, memory extraction repeatedly logged provider failures. Several SessionCommit messages remained in processing, while new messages accumulated in pending. The server stayed at high CPU even though the upstream request was rejected and the queue did not make progress.

The affected tasks were all associated with one session and had been generated repeatedly by an agent integration. The session metadata showed 287 commits and 4,374 total messages.

Minimal Reproducible Example

No standalone application-level reproducer is attached yet. The issue was observed with the persistent Docker deployment and the session commit queue under a provider that consistently returned HTTP 403.

Error Logs

volcenginesdkarkruntime._exceptions.ArkPermissionDeniedError:
Error code: 403 - {
  'error': {
    'code': 'AccountOverdueError',
    'message': 'The request failed because your account has an overdue balance.',
    'type': 'Forbidden'
  }
}

openviking.storage.queuefs.queue_manager - ERROR -
[QueueManager] Concurrent worker error for SessionCommit:
Expecting value: line 1 column 1 (char 0)

Environment

  • OpenViking: v0.4.13 Docker image, local image openviking-with-bot:local
  • Python: 3.13.14 inside the container
  • OS: macOS 14.5
  • Container runtime: Docker 29.4.0 via OrbStack 2.2.3
  • Model backend: Volcengine (Doubao)
  • Configured model roles: Volcengine embedding and VLM endpoints
  • Deployment: Docker Compose with persistent mounts for ~/.openviking/data and QueueFS

Additional Context

The issue was diagnosed from a live environment. No credentials or session message contents are included here.

The provider billing restriction was still present during observation. Regardless of whether the provider error is later fixed, the queue lifecycle behavior needs investigation: non-retryable provider errors should not leave worker slots and queue entries occupied indefinitely.

hua03 avatar Aug 21 '26 02:08 hua03

I attempted to reproduce this against current upstream daf5fb17 and compared the relevant paths with the v0.4.13 source.

Using an in-memory FS/TaskStore and the actual Session.resume_queued_commit and SessionCommitProcessor.on_dequeue paths, I injected the provider failure:

Error code: 403 - AccountOverdueError

The observed result was:

  • one provider call, with no retry or requeue;
  • the task reached failed;
  • .failed.json was written with stage="memory_extraction";
  • the processor reported success=1, requeue=0, error=0, so the normal queue path proceeded to acknowledgement.

This reproduces the terminal-failure handling, but not the reported long-lived processing entries or sustained high CPU. The focused queue, retry, SessionCommit, and 403 terminal-error tests also pass.

The v0.4.13 source already contains the same 403 classification and terminal failure handling, so the report does not appear to be explained by a missing auth-error branch alone. I did not run a real Volcengine request or a Docker deployment with persistent QueueFS.

Your report already includes the main environment details (v0.4.13, openviking-with-bot:local, Python 3.13.14, macOS/OrbStack, persistent QueueFS, and Volcengine).

The remaining details that would help narrow the difference between the reported deployment and the normal handled-403 path are the source commit used to build the local image, the concrete QueueFS implementation/configuration, and the full traceback for Expecting value: line 1 column 1 (char 0), including the parser or queue entry where it occurs.

ranxi2001 avatar Aug 21 '26 02:08 ranxi2001

Thanks for investigating this. I found an important difference between the isolated reproduction and the affected deployment.

Deployment details

  • OpenViking: v0.4.13
  • Image source revision: 03bd4694178f1ba9a33abbb194622b6b7a1c030d
  • Image digest: sha256:fa35c53d4db9b059c5161dffcda7535cf2bef55ac825bf04c33715a0849d8f15
  • Image build: a local image based on ghcr.io/volcengine/openviking:latest, followed by installation of the matching openviking[bot] package
  • Runtime: Docker linux/amd64 on macOS via OrbStack
  • QueueFS: persistent SQLite backend using the default queue database under the mounted OpenViking data directory
  • No explicit queue_workers or QueueFS overrides were present in ov.conf
  • Observed SessionCommit concurrency was 4

The only log entry for the JSON parsing error was:

[QueueManager] Concurrent worker error for SessionCommit: Expecting value: line 1 column 1 (char 0)

Unfortunately, this path did not emit a deeper traceback, so I do not have the parser or queue-entry-level traceback. The affected queue database was backed up before recovery, but the original entries were then removed to restore the service.

Sustained-failure workload

The queue was not handling only a single injected 403. A local autonomous coding task was continuously running while the same Volcengine account was overdue. The task and OpenViking used the same provider account, so both systems independently received AccountOverdueError while continuing their respective retry/workflow behavior.

For the affected Pi session:

  • runtime: approximately 12.5 hours;
  • 1,966 automated goal-continuation prompts;
  • 2,077 provider AccountOverdueError responses;
  • 4,374 messages synchronized to OpenViking;
  • 287 OpenViking session commits;
  • 98 OpenViking memory-extraction failures logged for this session.

The first provider 403 in the local task occurred at 2026-08-20T14:10:23Z. OpenViking logged its first corresponding provider failure approximately 35 seconds later. After several hours of sustained failures, the persistent QueueFS path logged the JSON parsing error above.

The observed stuck state was:

SessionCommit: 185 pending, 4 processing
openviking container: approximately 110%-145% CPU

Resolving the provider billing issue stopped the 403 responses, but the processing workers did not recover automatically. Restarting the container allowed some processing to resume; however, the oversized session then produced HTTP 400 InvalidParameter errors because the accumulated context exceeded the model message-token limit. After backing up the queue database and removing only the stale SessionCommit pending/processing entries, the queue remained empty and container CPU dropped to approximately 5%.

This suggests the relevant reproduction may require repeated SessionCommit submissions over a persistent SQLite QueueFS with concurrent workers while the provider continuously returns a terminal 403. A single injected failure against an in-memory TaskStore appears to exercise a materially different workload and persistence path.

hua03 avatar Aug 21 '26 03:08 hua03

Thanks for the additional details. The workload matches the scheduling issue addressed by #3944: multiple commits from the same session could occupy all SessionCommit workers while waiting for earlier archives.

Your affected version, v0.4.13, predates that fix. Could you retry the same persistent SQLite QueueFS workload with v0.4.14 or a newer release, while keeping the same provider failure and concurrency settings?

If the processing entries and CPU growth no longer occur, this issue was likely addressed by #3944. If they still occur, the remaining Expecting value path would be a separate QueueFS or archive-marker failure that needs investigation.

ranxi2001 avatar Aug 21 '26 03:08 ranxi2001

I ran an isolated local A/B replay using the same pre-recovery persistent SQLite QueueFS snapshot. The currently running OpenViking service and its live data were not modified.

Test setup

  • QueueFS snapshot initial state: 149 pending, 5 processing SessionCommit rows
  • Same archived session data from the affected deployment
  • Default SessionCommit concurrency: 4
  • Separate temporary data volumes for each version
  • Provider network access disabled to produce sustained retryable provider connection failures
  • Versions compared: v0.4.13 and v0.4.15

The injected failure was a retryable connection failure rather than the exact terminal 403 AccountOverdueError. This keeps provider processing failing and retrying while allowing the SessionCommit scheduling behavior to be compared without making real provider requests.

v0.4.13 result

After recovery from the QueueFS snapshot, the service remained at:

SessionCommit: 144 pending, 4 processing, 0 requeued
CPU: approximately 101%-141%

All four SessionCommit workers remained occupied for the observation period. This closely reproduced the original deployment state and CPU range.

Observer output near the end of the run:

SessionCommit: pending=144, in_progress=4, processed=6, requeued=0, errors=0

v0.4.15 result

Using a fresh copy of the same snapshot and the same failure condition:

SessionCommit: 146 pending, 1 processing
CPU after startup: approximately 12%-23%

Observer output:

SessionCommit: pending=146, in_progress=1, processed=606, requeued=599, errors=0
healthy=true

The processed/requeued counts are dequeue attempts, not distinct tasks. Later archives repeatedly deferred and released their workers, while only one runnable predecessor occupied a worker.

I also ran a deterministic differential test directly against the real scheduling methods in both images with four later archives waiting on the same-session predecessor:

v0.4.13: blocked_workers=4, requeued=0
v0.4.15: blocked_workers=0, requeued=4

This strongly supports that #3944 addresses the worker saturation and sustained CPU behavior reported here.

The Expecting value: line 1 column 1 (char 0) error did not recur during the v0.4.15 replay. However, because this was a bounded replay and used a connection failure rather than the exact 403 response, I cannot conclude that the JSON parsing path is fixed; it may still be a separate issue.

hua03 avatar Aug 21 '26 06:08 hua03

Thanks for running the differential replay. The same snapshot plus the scheduling-level comparison isolates the primary issue: #3944 addresses the SessionCommit worker saturation and sustained CPU behavior, and v0.4.14+ contains that scheduling change.

The JSON parsing error remains unconfirmed because it did not recur and the original queue row/traceback is no longer available. If it reproduces on a current release, it would be clearer to track it separately with the affected row and traceback.

No additional code change appears necessary for #4179. I think this issue can be closed as fixed by #3944.

ranxi2001 avatar Aug 21 '26 08:08 ranxi2001

Closing as fixed by #3944, which is included in v0.4.14+.

The reproduced worker-saturation/high-CPU behavior was resolved in the v0.4.15 replay:

  • v0.4.13: 4 blocked SessionCommit workers, CPU 101%-141%
  • v0.4.15: later same-session commits were requeued, only 1 task remained processing, CPU dropped to 12%-23%, and the queue was healthy.

The JSON parsing error (Expecting value: line 1 column 1 (char 0)) did not recur during the v0.4.15 replay. If it reproduces on a current release, it should be tracked separately with the affected queue row and full traceback.

sponge225 avatar Aug 24 '26 03:08 sponge225