peerdb icon indicating copy to clipboard operation
peerdb copied to clipboard

DropFlow: remove context deadline in shutdown flow

Open Amogh-Bharadwaj opened this issue 1 year ago • 1 comments

Not sure why we are setting a context deadline of 5 minutes for drop flow because after 5 minutes we are anyways performing handleCancelWorkflow in the event of drop flow taking a long time (to drop the slot etc)

Currently the context is getting cancelled after 5 minutes, taking us to the first case:

	case err := <-errChan:
		if err != nil {
			slog.Error(fmt.Sprintf("unable to cancel PeerFlow workflow: %s. Attempting to terminate.", err.Error()))
			terminationReason := fmt.Sprintf("workflow %s did not cancel in time.", workflowID)
			if err := h.temporalClient.TerminateWorkflow(ctx, workflowID, runID, terminationReason); err != nil {
				return fmt.Errorf("unable to terminate PeerFlow workflow: %w", err)
			}
		}

and erroring out

Amogh-Bharadwaj avatar Nov 26 '24 03:11 Amogh-Bharadwaj

nit: the workflow itself can run indefinitely, it's only the .Get call that gets cancelCtx so it waits 5 minutes for the result basically

I agree the select branches for DropFlow seem redundant (the cancel branch that we probably wanted will almost never be taken); but the core decision to take here is whether we want DropFlow to run indefinitely or not.

If we want to timebox DropFlow we can remove the time.After branch and have errChan branch cancel the workflow; if we want it to run indefinitely we don't cancel the workflow and return no error

heavycrystal avatar Nov 26 '24 05:11 heavycrystal

Less of an issue now that drop api is async

serprex avatar Jun 11 '25 11:06 serprex