Compactor case clause error
- Dominant language
- Erlang
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 9
Description
Noticed a shard that could not be compacted. The compaction would start then would crash.
```
{function_clause,[
{couch_bt_engine_compactor,'-copy_docs/4-inlined-2-',[
{3,<<138,72,.....>>},
[],
leaf,
{0,0,[]}
], [{file,"src/couch_bt_engine_compactor.erl"},{line,407}]
},
{couch_key_tree,mapfold_simple,4,[{file,"src/couch_key_tree.erl"},{line,465}]},
{couch_key_tree,mapfold_simple,4,[{file,"src/couch_key_tree.erl"},{line,474}]},
{couch_key_tree,mapfold,3,[{file,"src/couch_key_tree.erl"},{line,458}]},
{couch_bt_engine_compactor,'-copy_docs/4-fun-5-',3,[{file,"src/couch_bt_engine_compactor.erl"},{line,406}]},
{lists,map_1,2,[{file,"lists.erl"},{line,1320}]},
{lists,map_1,2,[{file,"lists.erl"},{line,1320}]},
{lists,map,2,[{file,"lists.erl"},{line,1315}]}
]}
```
That seems to come from:
https://github.com/apache/couchdb/blob/a326cdc53b962789f1d5a069d37177dcffe86cfb/src/couch/src/couch_bt_engine_compactor.erl#L408 where we get `[]` instead of `#leaf{ptr = Sp} = Leaf`.
The only fix so far is to delete the copy and let the other nodes re-replicate the data.
Contributor guide
Research direction
Start with src/couch_bt_engine_compactor.erl around lines 406-408 and trace the copy_docs/4 call shown in the crash. Compare the expected leaf value with the [] value reaching the function_clause, then validate the change by compacting an affected shard and confirming the crash no longer occurs.
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
- Mostly clear
- Newbie friendliness
- 35/100