Kaynağa Gözat

test+docs: 2.13.1 - outcome_unknown reaches every write's FailureDetail

Asked by smartbotic, whose adapter classifies patch/update/updateIfVersion/
remove/increment from the out-parameter rather than a thrown error. The
frozen phase of test_read_failures now also checks updateIfVersion and
removeAs through FailureDetail, and that update() timing out on its own read
(the write never sent) is DeadlineExceeded WITHOUT outcome_unknown. 67/67.
The guide says where the reason appears, and states positively that a body
which carried the reserved metadata names was harmless (smartbotic's
verification of its own write sites).
fszontagh 1 ay önce
ebeveyn
işleme
29deec0cc3

+ 14 - 0
docs/integration-guide.md

@@ -369,6 +369,13 @@ repeating it cannot change or misreport the result:
 | `patch` (no increments, no expected version), `upsert` with an id | yes - idempotent |
 | `insert`, `upsert` without an id, `increment`, `patchIfVersion`, `updateIfVersion`, `update`'s inner write, `remove`/`removeAs`/`removeManyAs` | no - a repeat would duplicate a row, count twice, or report a false AlreadyExists / version conflict / not-found |
 
+The reason is set wherever the failure is reported: on the thrown error
+(`errorDetail(e)`) for `insert`/`upsert`, and on the `Failure`/`FailureDetail`
+out-parameter for `patch`, `increment`, `updateIfVersion`, `update`, `remove`/
+`removeAs` and `removeManyAs`. `update()` reads before it writes: a timeout on
+that read means the write was never sent, so it is `DeadlineExceeded` WITHOUT
+`outcome_unknown` - the outcome is known, nothing happened.
+
 `Unavailable` and `ResourceExhausted` are still retried: the server did not act.
 **Do not map `DeadlineExceeded` on a write to "retry as-is".** With
 `outcome_unknown`, read the row first (or write under a fixed id) and decide.
@@ -679,6 +686,13 @@ fields that every read then hid: invisible, unfilterable (a filter on `_version`
 means the metadata), and carried into exports. Exports omit any such copies older
 rows still hold.
 
+**What this means for code that already writes them:** nothing breaks. A body
+that carried these names was stored with them as hidden fields that no read
+returned; now they are simply not stored. Either way every read reports the
+real metadata, and a value written under one of these names was never readable
+back. Decorating a document with `_id` AFTER `insert()` returns (for a response,
+say) never reached the database at all.
+
 ### Views
 
 Views are named, read-only projections over collections. They filter which fields are returned and optionally enforce baked-in filters and default sort order. Views are ideal for:

+ 18 - 0
tests/load_test/test_read_failures.cpp

@@ -176,6 +176,24 @@ static void writeTimeouts() {
        "frozen: a timed-out increment says outcome_unknown");
     ck(el < 1200, "frozen: an increment is NOT retried, it would count twice (" + std::to_string(el) + " ms)");
 
+    // The reason reaches the FailureDetail OUT-PARAMETER of every write, not
+    // only the thrown error (asked by smartbotic, whose adapter classifies
+    // patch/update/updateIfVersion/remove/increment from it).
+    Client::FailureDetail vd;
+    (void)w.updateIfVersion("things", "t1", nlohmann::json{{"k", 3}}, 1, vd);
+    ck(vd.code == Client::ErrorCode::DeadlineExceeded && vd.reason == "outcome_unknown",
+       "frozen: updateIfVersion's FailureDetail says outcome_unknown");
+    Client::FailureDetail rd;
+    (void)w.removeAs("things", "t1", "tester", rd);
+    ck(rd.code == Client::ErrorCode::DeadlineExceeded && rd.reason == "outcome_unknown",
+       "frozen: removeAs's FailureDetail says outcome_unknown");
+    // update() READS first: a timeout there means the write was never sent,
+    // so the outcome is known (nothing happened) and the reason says nothing.
+    Client::FailureDetail ud;
+    (void)w.update("things", "t1", nlohmann::json{{"k", 4}}, ud);
+    ck(ud.code == Client::ErrorCode::DeadlineExceeded && ud.reason.empty(),
+       "frozen: update() timing out on its read is NOT outcome_unknown ('" + ud.reason + "')");
+
     t = clk::now();
     Client::Failure rf;
     (void)w.remove("things", "t1", rf);