noahshaw11 commented on a change in pull request #3766:
URL: https://github.com/apache/couchdb/pull/3766#discussion_r807130541



##########
File path: src/smoosh/src/smoosh_channel.erl
##########
@@ -194,18 +224,139 @@ handle_info(check_window, State0) ->
         end,
     erlang:send_after(60 * 1000, self(), check_window),
     {noreply, FinalState};
-handle_info(pause, State0) ->
-    {ok, State} = code_change(nil, State0, nil),
+handle_info(start_recovery, #state{name = Name, waiting = Waiting0} = State0) 
->
+    RecActive = recover(active_file_name(Name)),
+    Waiting1 = lists:foldl(
+        fun(DbName, Acc) ->
+            case couch_db:is_compacting(DbName) of
+                true ->
+                    Priority = smoosh_server:get_priority(Name, DbName),
+                    smoosh_priority_queue:in(DbName, Priority, Priority, Acc);
+                false ->
+                    Acc
+            end
+        end,
+        Waiting0,
+        RecActive
+    ),
+    State1 = maybe_start_compaction(State0#state{paused = false, waiting = 
Waiting1}),
+    couch_log:notice(
+        "~p Previously active compaction jobs (if any) have been successfully 
recovered and restarted.",
+        [?MODULE]
+    ),
+    erlang:send_after(?ACTIVATE_DELAY_IN_MSEC, self(), activate),
+    {noreply, State1#state{paused = true}};
+handle_info(activate, #state{name = Name, waiting = Waiting0, requests = 
Requests0} = State0) ->
+    RecStarting = recover(starting_file_name(Name)),
+    Starting = lists:foldl(
+        fun(DbName, Acc) ->
+            Priority = smoosh_server:get_priority(Name, DbName),
+            smoosh_priority_queue:in(DbName, Priority, Priority, Acc)
+        end,
+        Waiting0,
+        RecStarting
+    ),
+    Requests1 = lists:reverse(Requests0),
+    Waiting1 = lists:foldl(
+        fun({DbName, Priority}, Acc) ->
+            smoosh_priority_queue:in(DbName, Priority, Priority, Acc)
+        end,
+        Starting,
+        Requests1
+    ),
+    State1 = maybe_start_compaction(State0#state{
+        waiting = Waiting1, paused = false, requests = []
+    }),
+    handle_info(persist_queue, State1),
+    {noreply, State1#state{paused = true, activated = true}};
+handle_info(persist_queue, #state{waiting = Queue} = State) ->
+    write_state_to_file(State),
+    smoosh_priority_queue:write_to_file(Queue),

Review comment:
       Seems that the call got lost in all of the changes to the recovery 
process. I have added the logic back and made the appropriate call.




-- 
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]


Reply via email to