iilyak commented on code in PR #5651:
URL: https://github.com/apache/couchdb/pull/5651#discussion_r2344277249
##########
src/dreyfus/src/dreyfus_index_manager.erl:
##########
@@ -66,6 +69,14 @@ handle_call({get_index, DbName, #index{sig = Sig} = Index},
From, State) ->
[{_, ExistingPid}] ->
{reply, {ok, ExistingPid}, State}
end;
+handle_call({reopen, DbName, #index{sig = Sig} = Index}, From, State) ->
+ case ets:lookup(?BY_SIG, {DbName, Sig}) of
+ [{_, ExistingPid}] when is_pid(ExistingPid) ->
+ true = ets:delete(?BY_SIG, {DbName, Sig});
+ _ ->
+ ok
+ end,
+ handle_call({get_index, DbName, Index}, From, State);
Review Comment:
If we're going to introduce a delay, then my original PR would be more
suitable for that approach. However, I was hoping we could avoid adding a delay
altogether, since tuning the right value for it is difficult. The propagation
of the EXIT signal from a remote node depends on the load on the TCP socket
used by the Erlang distribution protocol, which makes timing unpredictable.
The idea behind this PR is to remove the entry from BY_SIG, which forces the
creation of a new Pid via:
```erlang
Pid = spawn_link(fun() -> new_index(DbName, Index) end)
```
in the `handle_call({get_index, ...})` handler.
I chose not to explicitly kill `ExistingPid` or directly call
`delete_from_ets/3` because I wanted to preserve the existing code path that
handles the `EXIT` signal event.
--
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]