Skip to content

Writer degrades to busy polling after reconnection #252

Closed
@anarthal

Description

@anarthal

After a successful reconnection, the writer task revers to doing busy polling, rather than waiting for notifications, yielding in a high CPU usage. This is due to the following lines changing the expiry of the writer timer:

// It is safe to use the writer timer here because we are not
// connected.
conn_->writer_timer_.expires_after(conn_->cfg_.reconnect_wait_interval);

Timers are stateful, and keep the set expiration time. When a wait is issued against a timer with an expiry date in the past, it completes immediately, hence yielding the aforementioned busy wait situation.

I discovered this while implementing the tests for #250. The fix is trivial - using a separate timer for waits. This also simplifies the logic of #250. I will issue a PR shortly. I've opened the issue to keep track of it, in case anyone has experienced it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions