Expose atClusterTime parameter in snapshot sessions

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Sessions
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      This ticket was split from DRIVERS-2782, please see that ticket for a detailed description.


      Overview

      The specification change (DRIVERS-2782) exposes snapshotTime to applications, allowing them to:

      1. Set a snapshotTime when creating a snapshot session
      2. Get the snapshotTime from an existing snapshot session

      Why we should make this change

      MongoDB allows users to read data from a specific point in time (called a snapshot). Right now, the timestamp marking that point in time (atClusterTime) is a non-public prop inside the Session and can't be accessed or reused. This prevents common scenarios like ensuring different services see the same snapshot of data, or running long processes that need consistent reads throughout. By exposing atClusterTime, users can capture that timestamp from one session and use it to create new sessions with the same snapshot, something customers have been requesting but can't do today.

      Proposed Implementation Changes

      1. Add snapshotTime to ClientSessionOptions interface (src/sessions.ts)
      2. Expose snapshotTime as a public readonly property on ClientSession
      3. Update ClientSession constructor logic
      4. Add validation in constructor
      5. Update unified test runner (for test support)
      6. Add prose tests (test/integration or test/manual)

      Sample Code Changes

      Change 1: Update ClientSessionOptions interface

      // node-mongodb-native/src/sessions.ts
      export interface ClientSessionOptions {
          causalConsistency?: boolean;
          snapshot?: boolean;
          snapshotTime?: Timestamp;  // ADD THIS
          defaultTransactionOptions?: TransactionOptions;
          // ... other options
      }
      

      Change 2: Update ClientSession class

         export class ClientSession {
           // Change from @internal to public
           public readonly snapshotTime?: Timestamp;  // MAKE PUBLIC
       
           // Add getter with validation
           get snapshotTime(): Timestamp | undefined {
             if (!this.snapshotEnabled){
                throw new MongoInvalidArgumentError(
                  'snapshotTime can only be accessed on snapshot sessions'
                );
              }
             return this._snapshotTime;
           }
         }
      

      Acceptance Criteria

      Reference

            Assignee:
            Unassigned
            Reporter:
            TPM Jira Automations Bot
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: