apache / apache/couchdb

create_if_missing doesn't always take effect

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

Description

In the logs we see:

```
[warning] 2022-12-01T06:27:19.402535Z couchdb@couchdb-couchdb-1.couchdb-couchdb.drive-app.svc.cluster.local <0.1954.0> -------- mem3_sync shards/00000000-7fffffff/manifests-0038211.1669809395 couchdb@couchdb-couchdb-0.couchdb-couchdb.drive-app.svc.cluster.local {{rexi_EXIT,{{error,missing_target},[{mem3_util,get_or_create_db,2,[{file,[115,114,99,47,109,101,109,51,95,117,116,105,108,46,101,114,108]},{line,525}]},{mem3_rpc,load_checkpoint_rpc,4,[{file,[115,114,99,47,109,101,109,51,95,114,112,99,46,101,114,108]},{line,122}]},
```

load_rpc_checkpoint https://github.com/apache/couchdb/blob/f13ceb46ce3c120e1960fa47bfda0a606601900e/src/mem3/src/mem3_rpc.erl#L107-L110

calls get_or_create
https://github.com/apache/couchdb/blob/f13ceb46ce3c120e1960fa47bfda0a606601900e/src/mem3/src/mem3_util.erl#L606-L612

And there oddly enough, even with a `[{create_if_missing, true}]` we still catch `error:database_does_not_exist` error.

It could be from trying to load validation functions, security, shard doc, design docs or something of that type which blows up.

Perhaps?

https://github.com/apache/couchdb/blob/f13ceb46ce3c120e1960fa47bfda0a606601900e/src/couch/src/couch_db.erl#L977-L979

But I don't see how'd call that from this context: https://github.com/apache/couchdb/blob/f13ceb46ce3c120e1960fa47bfda0a606601900e/src/couch/src/couch_server.erl#L108-L129

Contributor guide

Open the contributing guide

Research direction

Start with the linked paths in src/mem3/src/mem3_rpc.erl and src/mem3/src/mem3_util.erl, especially load_rpc_checkpoint and get_or_create. Trace how create_if_missing is passed and where database_does_not_exist is raised, then inspect the referenced couch_db.erl and couch_server.erl sections. Done means identifying why the option is not honored and adding a regression test for the missing-target case.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.