Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion source/sessions/snapshot-sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class ClientSession {
}
```

Getting the value of `snapshotTime` on a non-snapshot session MUST raise an error.
The `snapshotTime` field MUST be read-only; in APIs that expose `snapshotTime` with a getter, attempting to read it on a
non-snapshot session MUST raise an error.

Transactions are not allowed with snapshot sessions. Calling `session.startTransaction(options)` on a snapshot session
MUST raise an error.
Expand Down Expand Up @@ -270,6 +271,7 @@ C# driver will provide the reference implementation. The corresponding ticket is

## Changelog

- 2025-12-17: Clarify snapshotTime semantics: the field is either read-only or validated.
- 2025-09-23: Exposed snapshotTime to applications.
- 2024-05-08: Migrated from reStructuredText to Markdown.
- 2021-06-15: Initial version.
Expand Down
12 changes: 11 additions & 1 deletion source/sessions/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,20 @@ Snapshot sessions tests require server of version 5.0 or higher and replica set

Snapshot sessions tests require server of version 5.0 or higher and replica set or a sharded cluster deployment.

- Start a session by calling `startSession` on with `snapshot = false`.
- Start a session by calling `startSession` with `snapshot = false`.

Drivers SHOULD implement one of the following approaches:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can say this is not a 2 approaches, this is simply 2 requirements:

  1. snapshot time should throw if snapshot = false (or return some special "Invalid" value if throwing is not an option).
  2. snapshot MUST be immutable.


**Approach 1: Validation (preferred if idiomatic)**

- Try to access the session's snapshot time.
- Assert that a client side error was raised.

**Approach 2: Ensure Read-Only (if error-returning getters are not idiomatic)**

- Attempt to mutate the session's `snapshotTime` field through any publicly accessible API.
Copy link
Member

@sanych-sun sanych-sun Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this statement conflicts with requirement of immutability?

The snapshotTime field MUST be immutable
A readonly property called snapshotTime will be added to ClientSession that allows applications to retrieve the
snapshot time of the session:

Why would we have any public API to mutate the value? Or we are talking about a languages with no technical ability to make the field readonly?

- Assert that the original session's `snapshotTime` remains unchanged.

## Changelog

- 2025-09-25: Added tests for snapshotTime.
Expand Down
Loading