nickva commented on issue #4809:
URL: https://github.com/apache/couchdb/issues/4809#issuecomment-1765685906
This seems to reproduce it:
```
diff --git a/src/couch_index/src/couch_index_server.erl
b/src/couch_index/src/couch_index_server.erl
index 35df43d2a..a40ea0e2a 100644
--- a/src/couch_index/src/couch_index_server.erl
+++ b/src/couch_index/src/couch_index_server.erl
@@ -171,6 +171,7 @@ handle_call({async_open, {DbName, DDocId, Sig}, {ok,
Pid}}, {OpenerPid, _}, Stat
[{_, Waiters}] = ets:lookup(State#st.by_sig, {DbName, Sig}),
[gen_server:reply(From, {ok, Pid}) || From <- Waiters],
link(Pid),
+ timer:sleep(100),
ets:delete(State#st.openers, OpenerPid),
add_to_ets(DbName, Sig, DDocId, Pid, State),
{reply, ok, State};
```
Async open returns too early an index process to the caller. In the index
server we have an opener still in openers and haven't added the new process to
the other ets tables.
At this point the caller gets the index Pid and kills it. This kills both
index and the still linked opener.
Client calls `get_index(...)` again, while that call is in the queue, the
index server continues the `async_open` handler and deletes the
`ets:delete(State#st.openers, OpenerPid)`. Then starts handling `EXIT` messages.
First is the indexer `EXIT` message. This is handled in:
```erlang
case ets:lookup(Server#st.by_pid, Pid) of
[{Pid, {DbName, Sig}}] -> ...
```
However when the opener `EXIT` is handled, we don't find the `Pid` in the
`by_pid` or the openers table and we crash the gen_server.
```erlang
case ets:lookup(Server#st.openers, Pid) of
... -> ...;
[] ->
exit(Reason)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]