Skip to content

Commit ccb9816

Browse files
authored
DRIVERS-2091: remove references to getLastError (#1698)
1 parent a32d445 commit ccb9816

File tree

4 files changed

+14
-36
lines changed

4 files changed

+14
-36
lines changed

source/read-write-concern/read-write-concern.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -298,19 +298,6 @@ writeConcern = { w: 0, wtimeoutMS: 100 }; // Unacknowledged
298298

299299
#### On the Wire
300300

301-
##### OP_INSERT, OP_DELETE, OP_UPDATE
302-
303-
`WriteConcern` is implemented by sending the `getLastError` (GLE) command directly after the operation. Drivers SHOULD
304-
piggy-back the GLE onto the same buffer as the operation. Regardless, GLE MUST be sent on the same connection as the
305-
initial write operation.
306-
307-
When a user has not specified a `WriteConcern` or has specified the server's default `WriteConcern`, drivers MUST send
308-
the GLE command without arguments. For example: `{ getLastError: 1 }`
309-
310-
Drivers MUST NOT send a GLE for an `Unacknowledged WriteConcern`. In this instance, the server will not send a reply.
311-
312-
See the `getLastError` command documentation for other formatting.
313-
314301
##### Write Commands
315302

316303
The `insert`, `delete`, and `update` commands take a named parameter, `writeConcern`. See the command documentation for
@@ -523,11 +510,7 @@ Below are English descriptions of other items that should be tested:
523510
### WriteConcern
524511

525512
1. Commands supporting a write concern MUST NOT send the default write concern to the server.
526-
2. Commands supporting a write concern MUST send any non-default acknowledged write concern to the server, either in the
527-
command or as a getLastError.
528-
3. On ServerVersion less than 2.6, drivers MUST NOT send a getLastError command for an Unacknowledged write concern.
529-
4. FindAndModify helper methods MUST NOT send a write concern when the MaxWireVersion is less than 4.
530-
5. Helper methods for other commands that write MUST NOT send a write concern when the MaxWireVersion is less than 5.
513+
2. Commands supporting a write concern MUST send any non-default write concern to the server in the command.
531514

532515
## Reference Implementation
533516

@@ -550,8 +533,6 @@ instance, we send it.
550533

551534
## Changelog
552535

553-
- 2024-08-23: Migrated from reStructuredText to Markdown.
554-
555536
- 2015-10-16: ReadConcern of local is no longer allowed to be used when talking with MaxWireVersion \< 4.
556537

557538
- 2016-05-20: Added note about helpers for commands that write accepting a writeConcern parameter.
@@ -593,6 +574,10 @@ instance, we send it.
593574

594575
- 2022-10-05: Remove spec front matter and reformat changelog.
595576

577+
- 2024-08-23: Migrated from reStructuredText to Markdown.
578+
579+
- 2024-10-30: Remove reference to getLastError
580+
596581
[^1]: This is only possible in a sharded cluster. When a write is routed to multiple shards and more than one shard
597582
returns a writeConcernError, then mongos will construct a new writeConcernError with the "WriteConcernFailed" error
598583
code and an errmsg field contains the stringified writeConcernError from each shard. Note that each shard may return

source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,6 @@ ServerDescription's error field.
5353

5454
Clients MUST NOT depend on any particular field order in these responses.
5555

56-
### getLastError
57-
58-
GLE response after OP_INSERT on an arbiter, secondary, recovering member, or ghost:
59-
60-
> {ok: 1, err: "not writable primary"}
61-
62-
[Possible GLE response in MongoDB 2.6](https://jira.mongodb.org/browse/SERVER-9617) during failover:
63-
64-
> {ok: 1, err: "replicatedToNum called but not master anymore"}
65-
66-
Note that this error message contains "not master" but does not start with it.
67-
6856
### Write command
6957

7058
Response to an "insert" command on an arbiter, secondary, recovering member, or ghost:

source/server-discovery-and-monitoring/server-discovery-and-monitoring.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ def parseGle(response):
11091109
if "err" in response:
11101110
handleError(CommandError(response, response["err"], response["code"]))
11111111

1112-
# Parse response to any command besides getLastError.
1112+
# Parse response to any command
11131113
def parseCommandResponse(response):
11141114
if not response["ok"]:
11151115
handleError(CommandError(response, response["errmsg"], response["code"]))
@@ -1169,8 +1169,8 @@ operation needs the server sooner than that, then a re-check will be triggered b
11691169

11701170
##### "not writable primary" and "node is recovering"
11711171

1172-
These errors are detected from a getLastError response, write command response, or query response. Clients MUST check if
1173-
the server error is a "node is recovering" error or a "not writable primary" error.
1172+
These errors are detected from a write command response or query response. Clients MUST check if the server error is a
1173+
"node is recovering" error or a "not writable primary" error.
11741174

11751175
If the response includes an error code, it MUST be solely used to determine if error is a "node is recovering" or "not
11761176
writable primary" error. Clients MUST match the errors by the numeric error code and not by the code name, as the code
@@ -1921,6 +1921,8 @@ oversaw the specification process.
19211921

19221922
## Changelog
19231923

1924+
- 2024-11-11: Removed references to `getLastError`
1925+
19241926
- 2024-11-04: Make the description of `TopologyDescription.servers` consistent with the spec tests.
19251927

19261928
- 2024-08-16: Updated host b wire versions in `too_new` and `too_old` tests

source/server_write_commands/server_write_commands.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,13 @@ It must convert that request into write operations + gle's and use the old op co
484484
485485
### Are we discontinuing the use of getLastError?
486486
487-
Yes but as of 2.6 the existing getLastError behavior is supported for backward compatibility.
487+
Yes but as of 2.6 the existing getLastError behavior is supported for backward compatibility. Note also that
488+
`getLastError` was removed in server version 5.1.
488489
489490
## Changelog
490491
492+
- 2024-11-11: Add note that getLastError has been removed from the server.
493+
491494
- 2024-07-31: Migrated from reStructuredText to Markdown.
492495
493496
- 2024-06-04: Add FAQ entry outlining client-side `_id` value generation Update FAQ to indicate legacy opcodes were

0 commit comments

Comments
 (0)