[SERVER-61197] Canceling a session should await completion of its operations on the baton Created: 02/Nov/21  Updated: 06/Dec/22  Resolved: 29/Nov/21

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Amirsaman Memaripour Assignee: Backlog - Service Architecture
Resolution: Won't Fix Votes: 0
Labels: servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-47229 Make TransportSessionASIO cancelation... Closed
Assigned Teams:
Service Arch
Operating System: ALL
Participants:

 Description   

When ending a session (i.e., an instance of transport::Session), we should ensure it awaits completion of any inflight operations on the networking baton, and then safely removes itself from the baton. Currently, this is not the case:

bool TransportLayerASIO::BatonASIO::cancelSession(Session& session) noexcept override {
    const auto id = session.id();
    stdx::unique_lock lk(_mutex);
    if (_sessions.find(id) == _sessions.end()) {
        return false;
    }
 
    _safeExecute(std::move(lk), [ id, this ](stdx::unique_lock<Mutex> lk) noexcept {
        auto iter = _sessions.find(id);
        if (iter == _sessions.end()) {
            return;
        }
        auto session = std::exchange(iter->second, {});
        _sessions.erase(iter);
        lk.unlock();
 
        session.promise.setError(kCanceled);
    });
    return true;
}

Since the baton uses the reactor thread to poll on the sessions, we should ensure the baton is not running anything on behalf of the session before removing it.



 Comments   
Comment by Amirsaman Memaripour [ 29/Nov/21 ]

Closed as "Won't Fix" in favor of other work described by SERVER-61192 and SERVER-54900.

Generated at Thu Feb 08 05:51:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.