agent-rs icon indicating copy to clipboard operation
agent-rs copied to clipboard

call_and_wait should add a delay between calls to request_status_raw

Open p-shahi opened this issue 3 years ago • 1 comments

        loop {
            match self.agent.request_status_raw(&request_id).await? {
…
                RequestStatusResponse::Unknown => (),
                RequestStatusResponse::Received | RequestStatusResponse::Processing => {
                    // The system will return Unknown until the request is accepted
                    // and we generally cannot know how long that will take.
                    // State transitions between Received and Processing may be
                    // instantaneous. Therefore, once we know the request is accepted,
                    // we restart the waiter so the request does not time out.
                    if !request_accepted {
                        waiter
                            .restart()
                            .map_err(|_| AgentError::WaiterRestartError())?;
                        request_accepted = true;
                    }
                }
…
            };

will very aggressively hammer the read endpoint, possibly starving that node. [There should be some delays here.]

p-shahi avatar Mar 02 '21 17:03 p-shahi

It seems we are using the Waiter to throttle. Are you using the proper Waiter instance?

https://github.com/dfinity/agent-rs/blob/next/ic-agent/src/agent/mod.rs#L603-L605

            waiter
                .wait()
                .map_err(|_| AgentError::TimeoutWaitingForResponse())?;

hansl avatar Apr 06 '21 21:04 hansl