Skip to content

Commit 0bc7fb6

Browse files
DRIVERS-2782 Allow variable access to snapshotTimeout (#1870)
1 parent cc99191 commit 0bc7fb6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

source/sessions/snapshot-sessions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ class ClientSession {
137137
}
138138
```
139139

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

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

271272
## Changelog
272273

274+
- 2025-12-17: Clarify snapshotTime semantics: the field is either read-only or validated.
273275
- 2025-09-23: Exposed snapshotTime to applications.
274276
- 2024-05-08: Migrated from reStructuredText to Markdown.
275277
- 2021-06-15: Initial version.

source/sessions/tests/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,20 @@ Snapshot sessions tests require server of version 5.0 or higher and replica set
270270

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

273-
- Start a session by calling `startSession` on with `snapshot = false`.
273+
- Start a session by calling `startSession` with `snapshot = false`.
274+
275+
Drivers SHOULD implement one of the following approaches:
276+
277+
**Approach 1: Validation (preferred if idiomatic)**
278+
274279
- Try to access the session's snapshot time.
275280
- Assert that a client side error was raised.
276281

282+
**Approach 2: Ensure Read-Only (if error-returning getters are not idiomatic)**
283+
284+
- Attempt to mutate the session's `snapshotTime` field through any publicly accessible API.
285+
- Assert that the original session's `snapshotTime` remains unchanged.
286+
277287
## Changelog
278288

279289
- 2025-09-25: Added tests for snapshotTime.

0 commit comments

Comments
 (0)