Skip to content

fix(openclaw-plugin): prevent CONFLICT errors with commit lock#1055

Closed
leckylao wants to merge 1 commit intovolcengine:mainfrom
leckylao:fix/concurrent-commit-lock
Closed

fix(openclaw-plugin): prevent CONFLICT errors with commit lock#1055
leckylao wants to merge 1 commit intovolcengine:mainfrom
leckylao:fix/concurrent-commit-lock

Conversation

@leckylao
Copy link
Copy Markdown

Problem

When using the OpenClaw plugin with auto-capture enabled, we frequently encounter CONFLICT errors:

Error: OpenViking request failed [CONFLICT]: Session agent:main:discord:channel:xxx already has a commit in progress

This happens when two code paths try to commit to the same OpenViking session simultaneously:

  1. afterTurn hook auto-capture
  2. memory_store tool explicit commit

Solution

Add a simple in-memory lock mechanism in context-engine.ts:

const commitLocks = new Set<string>();

async afterTurn(afterTurnParams): Promise<void> {
  // ...
  if (commitLocks.has(OVSessionId)) {
    logger.info(`openviking: afterTurn skipped (commit in progress for ${OVSessionId})`);
    return;
  }
  commitLocks.add(OVSessionId);

  try {
    // ... existing commit logic ...
  } catch (err) {
    // ... error handling ...
  } finally {
    commitLocks.delete(OVSessionId);
  }
}

Behavior

  • If a commit is already in progress for a session, afterTurn skips the auto-capture for that turn
  • The lock is released in finally block to ensure cleanup even on error
  • No data loss - the next turn will capture any missed messages

Testing

Tested on production OpenClaw instance with OpenViking 0.2.12. CONFLICT errors no longer appear.

When auto-capture in afterTurn and memory_store tool both try to commit
to the same OpenViking session simultaneously, the server returns a
CONFLICT error. This adds a simple in-memory lock mechanism:

- Add commitLocks Set to track in-flight commits per session
- Skip afterTurn if a commit is already in progress for that session
- Release lock in finally block to ensure cleanup on error

This prevents the error:
'OpenViking request failed [CONFLICT]: Session xxx already has a commit in progress'
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 28, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@Mijamind719
Copy link
Copy Markdown
Collaborator

Thank you for your submission. In the latest version of the code, we have added commit queues internally within OV, thus enabling concurrent commits on the client side.

@Mijamind719
Copy link
Copy Markdown
Collaborator

You can update the code to the latest version, or the latest v0.2.15.

@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants