Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug]: Error querying Nouveau indexes after purging

Closed
#6,118 7 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
erlang
Domain
backend, databases

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

bug
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

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/couchdb

All issues in apache/couchdb

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.