Skip to content

Possible deadlock and memory leak during connection timeouts #426

@ankurmittal

Description

@ankurmittal

Hi,
Today we faced a issue where of of our couchbase client host started failing with connection timeout (2.5s, our wrapper logic where we drop the future) for 4 hours. The memory grew overtime to 1.4GB and when we investigated we found that 1.25 gb of memory was taken by mpsc::channel

batch_upsert → buffer_unordered → upsert → Collection::upsert_raw
→ tokio::time::timeout → couchbase SDK upsert_raw
→ CrudComponent::upsert → orchestrate_retries → orchestrate_simple_crud
→ OpsCrud::set → StdKvClient::set
→ Client::dispatch
→ tokio::sync::mpsc::bounded::channel ← 1.25GB HERE
→ mpsc::block::Block::new
→ alloc

Upon further investigation we believe that there was a deadlock due to block-on in drop which can basically block the sender code from completing because receiver is on the same thread

I see you already mitigated it here 5bebfe0. Do you think we can mitigate the issue by updating to this PR? Also client never refreshed the bad connection. Do you have any insight on why that will happen? Is it because of the same issue? We are currently on commit be74b7a

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