iilyak commented on a change in pull request #3766:
URL: https://github.com/apache/couchdb/pull/3766#discussion_r767742682
##########
File path: src/smoosh/src/smoosh_channel.erl
##########
@@ -65,71 +64,82 @@ close(ServerRef) ->
flush(ServerRef) ->
gen_server:call(ServerRef, flush).
+is_key(ServerRef, Key) ->
+ gen_server:call(ServerRef, {is_key, Key}).
+
% gen_server functions.
init(Name) ->
schedule_unpause(),
erlang:send_after(60 * 1000, self(), check_window),
- {ok, #state{name = Name}}.
+ process_flag(trap_exit, true),
+ Queue = smoosh_priority_queue:new(Name),
+ State = #state{name=Name, waiting=Queue},
+ State1 = maybe_recover_state(State),
Review comment:
It think this could cause problems. The `maybe_recover_state/1` calls
`get_matching_compact_files` which can take longer than a timeout in the
application supervisor. Here is how it could fail.
- The
[`smoosh_sup`](https://github.com/apache/couchdb/blob/3.x/src/smoosh/src/smoosh_sup.erl#L38)
starts smoosh_server.
- The `smoosh_server` calls
[`create_missing_channels/1`](https://github.com/apache/couchdb/blob/3.x/src/smoosh/src/smoosh_server.erl#L130)
from its `init/1` function.
- The `create_missing_channels/1` calls
[`smoosh_channel:start_link(Channel)`](https://github.com/apache/couchdb/blob/3.x/src/smoosh/src/smoosh_server.erl#L338).
If `smoosh_channel:init/1` blocks it blocks `smoosh_server:init/1`, which
causes problems for supervisor.
There are two possible approaches here.
1. Send message to itself using `gen_server:cast` (there is some info here
https://pdincau.wordpress.com/2013/04/17/how-to-handle-configuration-in-init1-function-without-slowing-down-your-erlang-supervisor-startup/)
2. Using `proc_lib:start_link` and
[`proc_lib:init_ack/1`](https://www.erlang.org/doc/man/proc_lib.html#init_ack-1)
(so called special processess).
-
[couch_views_indexer.erl](https://github.com/apache/couchdb/blob/15cbb5502503c6e4d786bf0a85b7c225ccd14f71/src/couch_views/src/couch_views_indexer.erl#L50)
The gen_server:cast is easier to implement and should fit better in this
case.
--
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]