Transactions Background Part 2: Logical Sessions in MongoDB`
Logical sessions are a foundational change in MongoDB that enable tracking and cancellation of operations as they progress through a cluster. By creating a unique identifier, called the Logical Session Identifier (lsid), for each client operation, resources being used by that client can be tracked and cancelled with simplicity. This feature simplifies the process of cancelling operations, such as find() commands, which consume resources like cursors in shards. It also enables distributed garbage collection, where timeouts and garbage collection are aware of the cluster. Logical sessions have immediate utility in cancellation and garbage collection scenarios and are a foundation for other MongoDB 4.0+ features, including ensuring transactions take place within a session.