[Bug]: Error querying Nouveau indexes after purging
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with nouveau_index_updater.erl, especially purge_index and update, then trace the purge handling in couch_bt_engine.erl at fold_purge_infos. Reproduce repeated _purge calls against a database using Nouveau indexes if possible. Done means purging no longer leaves index updates out of order or produces invalid_start_purge_seq errors, with a regression test if the race can be reproduced.
Written by the indexing model from the issue text.
Description
Version
3.5.2
Describe the problem you're encountering
We are doing quite extensive purging (through the _purgeendpoint), we are also using Nouveau indexes.
In one instance, Nouveau index queries started failing consistently. This is the error we saw in CouchDb logs:
{{case_clause,{error,{conflict,<<"Index updates applied in the wrong order (current seq: 7439245, match seq: 7439245, attempted seq: 7438959)">>}}},[{couch_btree,stream_kv_node2,9,[{file,"src/couch_btree.erl"},{line,1315}]},{couch_btree,stream_kp_node,8,[{file,"src/couch_btree.erl"},{line,1241}]},{couch_btree,stream_kp_node,9,[{file,"src/couch_btree.erl"},{line,1286}]},{couch_btree,fold,4,[{file,"src/couch_btree.erl"},{line,283}]},{couch_bt_engine,fold_purge_infos,5,[{file,"src/couch_bt_engine.erl"},{line,607}]},{nouveau_index_updater,purge_index,3,[{file,"src/nouveau_index_updater.erl"},{line,288}]},{nouveau_index_updater,update,1,[{file,"src/nouveau_index_updater.erl"},{line,97}]}]}
[error] 2026-09-17T18:45:51.685469Z [email protected] <0.2024.0> -------- nouveau_index_manager: db:**** ddoc:**** failed with: {{case_clause,{error,{conflict,<<"Index updates applied in the wrong order (current seq: 7420581, match seq: 7420581, attempted seq: 7420405)">>}}},[{couch_btree,stream_kv_node2,9,[{file,"src/couch_btree.erl"},{line,1315}]},{couch_btree,stream_kp_node,8,[{file,"src/couch_btree.erl"},{line,1241}]},{couch_btree,stream_kp_node,9,[{file,"src/couch_btree.erl"},{line,1286}]},{couch_btree,fold,4,[{file,"src/couch_btree.erl"},{line,283}]},{couch_bt_engine,fold_purge_infos,5,[{file,"src/couch_bt_engine.erl"},{line,607}]},{nouveau_index_updater,purge_index,3,[{file,"src/nouveau_index_updater.erl"},{line,288}]},{nouveau_index_updater,update,1,[{file,"src/nouveau_index_updater.erl"},{line,97}]}]}
[error] 2026-09-17T18:45:51.685586Z [email protected] emulator -------- Error in process <0.111495.0> on node '[email protected]' with exit value:
The team deleted the affected reported nouveau index on disk, expecting the index rebuild to resolve the error. Instead, this is the error that is logged now:
{{invalid_start_purge_seq,0,180213},[{couch_bt_engine,fold_purge_infos,5,[{file,"src/couch_bt_engine.erl"},{line,601}]},{nouveau_index_updater,purge_index,3,[{file,"src/nouveau_index_updater.erl"},{line,288}]},{nouveau_index_updater,update,1,[{file,"src/nouveau_index_updater.erl"},{line,97}]}]}
The Nouveau container is not reporting any errors.
Expected Behaviour
Using _purge should preserve Nouveau indexes.
Steps to Reproduce
Repeatedly calling the _purge over a database that uses Nouveau indexes.
This only appeared on one instance and we were unable to replicate it in tests. It seems that a race condition is causing this.
Your Environment
Docker hosted CouchDb + Nouveau 3.5.2.
Additional Context
Can you please advise on steps to unblock this instance. Deleting one Nouveau index did not resolve this, but did change the error that was being thrown.
- Dominant language
- Erlang
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 1d 23m
- Merged PRs (30d)
- 30
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/couchdb
-
Fix: Warning: 'catch ...' is deprecated; please use 'try ... catch ... end' insteadPossibly taken @devx-arjun claimed this 4 days ago. Openbeginner-friendly build chore patches-welcome
Difficulty 4/5 3-5 days Newbie friendliness 45/100
apache/couchdb#6144 · 4 comments ·
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
apache/couchdb#6132 · 3 comments ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 45/100
apache/couchdb#6120 · 4 comments ·
Maintainers usually reply within 1 day
-
enhancement needs-triage
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
factory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
vercel/ai#22796 · 2 comments ·
Maintainers usually reply within 1 day
-
good first issue no-box
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
peasant-labs/peasant#596 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
hatchet-dev/hatchet#5179 ·
Maintainers usually reply within 1 day