Skip to content

Conversation

jiahuili430
Copy link
Contributor

Overview

Add a more general case statement in ken_server to handle when the database does not exist.

Error log:

{{case_clause,{error,{error,missing_target,[{mem3_util,get_or_create_db_int,2,[{file,"src/mem3_util.erl"},{line,627}]},{fabric_rpc,all_docs,3,[{file,"src/fabric_rpc.erl"},{line,157}]},{rexi_server,init_p,3,[{file,"src/rexi_server.erl"},{line,141}]}]}}},[{ken_server,update_db_indexes,2,[{file,"src/ken_server.erl"},{line,270}]}]}#012

Testing recommendations

Related Issues or Pull Requests

Checklist

  • Code is written and works correctly
  • Changes are covered by tests
  • Any new configurable parameters are documented in rel/overlay/etc/default.ini
  • Documentation changes were made in the src/docs folder
  • Documentation changes were backported (separated PR) to affected branches

Add a more general case statement in `ken_server` to handle when the
database does not exist.

Error log:

```log
{{case_clause,{error,{error,missing_target,[{mem3_util,get_or_create_db_int,2,[{file,"src/mem3_util.erl"},{line,627}]},{fabric_rpc,all_docs,3,[{file,"src/fabric_rpc.erl"},{line,157}]},{rexi_server,init_p,3,[{file,"src/rexi_server.erl"},{line,141}]}]}}},[{ken_server,update_db_indexes,2,[{file,"src/ken_server.erl"},{line,270}]}]}#12
```
Comment on lines +290 to +291
Else ->
exit(Else)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A missing target is essentially a database_does_not_exist case.

Something is off a missing target is something we should be seeing in the internal replicator not for places like design_docs()

@nickva
Copy link
Contributor

nickva commented Oct 3, 2025

I wonder if instead of exiting on missing_target we transform it into a database_does_not_exist error in

mem3_util:get_or_create_db_int(DbName, Options).

Looking around here is what found:

At some point in the past (#2690) we started using the mem3_util helper to create the db, which was a nice feature try DRY-up the logic

Screenshot 2025-10-03 at 2 24 00 PM

However, when doing that we forgot to consider that mem3_util will throw and return things specific to mem3 replicator and other bits from that application which may not be handled properly in fabric or other parts. For instance, in this case it throws a missing_target which makes no sense for ken, it doesn't deal with "targets" at all. So one way to fix it maybe to at least catch the missing_target throw in fabric_rpc and re-raise it as an database_does_not_exist error. Otherwise we may have to sprinkle missing_target catch and exception everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants