FerretDB
FerretDB copied to clipboard
`upsert`: the response from FerretDB is not the same as from proxy
FerretDB version (commit) to reproduce the problem: 0c96f230f5359602d99ac440b6b66a9c91ff539e
OS: MacOS
FerretDB is run via task run
How to reproduce
Perform findAndModify with upsert, for example:
db.hello.findAndModify({ query: { _id: 12345}, update: {"$set": {"v": 43}}, upsert: true})
Expected result
The responses from proxy and FerretDB are equal
Actual result
The responses are different:
2022-09-01T08:31:08.727+0200 DEBUG // 127.0.0.1:62708 -> 127.0.0.1:27017 clientconn/conn.go:438 Response message:
{
"Checksum": 0,
"FlagBits": 0,
"Sections": [
{
"Document": {
"$k": [
"lastErrorObject",
"value",
"ok"
],
"lastErrorObject": {
"$k": [
"n",
"updatedExisting",
"upserted"
],
"n": 1,
"updatedExisting": false,
"upserted": 12345
},
"value": {
"$k": [
"_id",
"v"
],
"_id": 12345,
"v": 43
},
"ok": {
"$f": 1
}
},
"Kind": 0
}
]
}
2022-09-01T08:31:08.730+0200 DEBUG // 127.0.0.1:62708 -> 127.0.0.1:27017 clientconn/conn.go:437 Proxy response header: length: 106, id: 78919, response_to: 45, opcode: OP_MSG
2022-09-01T08:31:08.731+0200 DEBUG // 127.0.0.1:62708 -> 127.0.0.1:27017 clientconn/conn.go:438 Proxy response message:
{
"Checksum": 0,
"FlagBits": 0,
"Sections": [
{
"Document": {
"$k": [
"lastErrorObject",
"value",
"ok"
],
"lastErrorObject": {
"$k": [
"n",
"updatedExisting",
"upserted"
],
"n": 1,
"updatedExisting": false,
"upserted": 12345
},
"value": null,
"ok": {
"$f": 1
}
},
"Kind": 0
}
]
}
2022-09-01T08:31:08.732+0200 DEBUG // 127.0.0.1:62708 -> 127.0.0.1:27017 clientconn/conn.go:223 Header diff:
--- res header
+++ proxy header
@@ -1 +1 @@
-length: 127, id: 7, response_to: 45, opcode: OP_MSG
+length: 106, id: 78919, response_to: 45, opcode: OP_MSG
Body diff:
--- res body
+++ proxy body
@@ -21,10 +21,3 @@
},
- "value": {
- "$k": [
- "_id",
- "v"
- ],
- "_id": 12345,
- "v": 43
- },
+ "value": null,
"ok": {
TODO:
- Find the current issue number mentioned in the compat tests for findAndModify, remove "skip", fix the problem and make tests pass
TODO: check that the fix fixed the problem mentioned in the issue
This is covered by https://github.com/FerretDB/FerretDB/blob/main/integration/findandmodify_compat_test.go#L249 and no issue number found in the code.