apache / apache/couchdb

error: function_clause, couch_btree:fold inside of compaction process

Open
#1,362 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Erlang
Stars
7k
Forks
1.1k
Avg merge
1d 16h
Merged PRs (30d)
9

Description

Under heavy load and insufficient CPU, a 3-node cluster produced a large number of function_clause errors. This is one of these errors.

```
{function_clause,[{couch_btree,fold,[undefined,#Fun,[],[{start_key,<<"_design/">>},{end_key_gt,<<"_design0">>}]],[{file,"src/couch_btree.erl"},{line,211}]},{couch_db,enum_docs,5,[{file,"src/couch_db.erl"},{line,1284}]},{couch_compaction_daemon,db_ddoc_names,1,[{file,"src/couch_compaction_daemon.erl"},{line,239}]},{couch_compaction_daemon,maybe_compact_db,3,[{file,"src/couch_compaction_daemon.erl"},{line,163}]},{couch_compaction_daemon,'-compact_loop/1-fun-0-',3,[{file,"src/couch_compaction_daemon.erl"},{line,141}]},{couch_server,'-all_databases/2-fun-0-',4,[{file,"src/couch_server.erl"},{line,273}]},{filelib,do_fold_files2,8,[{file,"filelib.erl"},{line,185}]},{filelib,do_fold_files2,8,[{file,"filelib.erl"},{line,195}]}]}
[error] 2018-05-28T03:07:54.298000Z couchdb@node1 <0.3283.3747> -------- gen_server couch_compaction_daemon terminated with reason: {compaction_loop_died,{function_clause,[{couch_btree,fold,[undefined,#Fun,[],[{start_key,<<"_design/">>},{end_key_gt,<<"_design0">>}]],[{file,"src/couch_btree.erl"},{line,211}]},{couch_db,enum_docs,5,[{file,"src/couch_db.erl"},{line,1284}]},{couch_compaction_daemon,db_ddoc_names,1,[{file,"src/couch_compaction_daemon.erl"},{line,239}]},{couch_compaction_daemon,maybe_compact_db,3,[{file,"src/couch_compaction_daemon.erl"},{line,163}]},{couch_compaction_daemon,'-compact_loop/1-fun-0-',...},...]}}
[error] 2018-05-28T03:07:54.298000Z couchdb@node1 <0.3283.3747> -------- CRASH REPORT Process couch_compaction_daemon (<0.3283.3747>) with 0 neighbors exited with reason: {compaction_loop_died,{function_clause,[{couch_btree,fold,[undefined,#Fun,[],[{start_key,<<"_design/">>},{end_key_gt,<<"_design0">>}]],[{file,"src/couch_btree.erl"},{line,211}]},{couch_db,enum_docs,5,[{file,"src/couch_db.erl"},{line,1284}]},{couch_compaction_daemon,db_ddoc_names,1,[{file,"src/couch_compaction_daemon.erl"},{line,239}]},{couch_compaction_daemon,maybe_compact_db,3,[{file,"src/couch_compaction_daemon.erl"},{line,163}]},{couch_compaction_daemon,'-compact_loop/1-fun-0-',...},...]}} at gen_server:terminate/7(line:826) <= proc_lib:init_p_do_apply/3(line:240); initial_call: {couch_compaction_daemon,init,['Argument__1']}, ancestors: [couch_secondary_services,couch_sup,<0.209.0>], messages: [], links: [<0.28626.3663>], dictionary: [], trap_exit: true, status: running, heap_size: 2586, stack_size: 27, reductions: 27257
```

Contributor guide

Open the contributing guide

Research direction

Start with couch_btree.erl:211 and trace the undefined value from couch_db.erl:1284 into couch_compaction_daemon.erl at db_ddoc_names/1 and maybe_compact_db/3. Reproduce the failure under heavy load with insufficient CPU if possible, then verify that compaction no longer terminates with this function_clause error.

Written by the indexing model from the issue text.

Assessment

Tech stack
erlang
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.