Просмотр исходного кода

feat: 2.13.0 - size refusals say message_too_large; batch_rows_cap

Both asked for by smartbotic-vectorapi during the pre-release run.

gRPC refuses an oversized message itself (either side) with
RESOURCE_EXHAUSTED and no detail, so a size refusal looked like a rate limit
or memory pressure though retrying never helps. The client now sets reason
message_too_large on that code when it carries gRPC core's 'message larger
than max' text and no server detail; the library owns the text dependency so
no consumer matches on it. test_export pins it with a get of a row larger
than its server's 2 MB send limit.

ExportHeader.batch_rows_effective -> batch_rows_cap (batchRowsCap): it is the
row cap after clamping, not the size of the batches, which the 8 MB cut makes
smaller for large rows. Unreleased, so renamed rather than documented around.

Recorded as ROADMAP 5b-3, not fixed here: a row can grow past the send limit
through repeated patches (then unreadable by get), and a large write can
report DeadlineExceeded after it was applied and then be retried.
fszontagh 1 месяц назад
Родитель
Сommit
013459a354

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
CLAUDE.md


+ 1 - 1
client/include/smartbotic/database/client.hpp

@@ -795,7 +795,7 @@ public:
         uint32_t vectorDimension = 0;
         uint32_t vectorDimension = 0;
         std::string vectorDtype;          ///< informational; the client converts ("float32-le")
         std::string vectorDtype;          ///< informational; the client converts ("float32-le")
         uint64_t rowsAtSnapshot = 0;      ///< rows this stream sends if it completes
         uint64_t rowsAtSnapshot = 0;      ///< rows this stream sends if it completes
-        uint32_t batchRowsEffective = 0;  ///< batch_rows after the server clamped it
+        uint32_t batchRowsCap = 0;        ///< the most rows one batch holds (requested, clamped); a batch also closes at 8 MB, so real batches can be smaller
         uint32_t maxStreamSeconds = 0;    ///< one stream ends (complete=false) after this
         uint32_t maxStreamSeconds = 0;    ///< one stream ends (complete=false) after this
     };
     };
 
 

+ 13 - 1
client/src/client.cpp

@@ -74,6 +74,18 @@ Client::FailureDetail makeDetail(Client::ErrorCode code, const std::string& mess
     Client::FailureDetail d;
     Client::FailureDetail d;
     d.code = code;
     d.code = code;
     d.message = message;
     d.message = message;
+    // v2.13.0 - gRPC refuses an oversized message itself (either side, before
+    // our server code runs), with RESOURCE_EXHAUSTED and no detail, so a size
+    // refusal looked exactly like a rate limit or memory pressure - and the
+    // remedies differ: retrying never shrinks a payload. The library names it,
+    // so no consumer has to match gRPC's text. The text is gRPC core's own
+    // ("Sent message larger than max (N vs. M)", also "Received message
+    // larger than max"), stable across the gRPC versions this is built with;
+    // test_export pins it.
+    if (detailJson.empty() && code == Client::ErrorCode::ResourceExhausted &&
+        message.find("message larger than max") != std::string::npos) {
+        d.reason = "message_too_large";
+    }
     if (detailJson.empty()) return d;
     if (detailJson.empty()) return d;
     try {
     try {
         const auto j = nlohmann::json::parse(detailJson);
         const auto j = nlohmann::json::parse(detailJson);
@@ -2242,7 +2254,7 @@ public:
                 out.vectorDimension = h.vector_dimension();
                 out.vectorDimension = h.vector_dimension();
                 out.vectorDtype = h.vector_dtype();
                 out.vectorDtype = h.vector_dtype();
                 out.rowsAtSnapshot = h.rows_at_snapshot();
                 out.rowsAtSnapshot = h.rows_at_snapshot();
-                out.batchRowsEffective = h.batch_rows_effective();
+                out.batchRowsCap = h.batch_rows_cap();
                 out.maxStreamSeconds = h.max_stream_seconds();
                 out.maxStreamSeconds = h.max_stream_seconds();
                 if (onHeader) {
                 if (onHeader) {
                     try { onHeader(out); } catch (...) { abandon(); throw; }
                     try { onHeader(out); } catch (...) { abandon(); throw; }

+ 16 - 0
docs/ROADMAP.md

@@ -299,6 +299,22 @@ A write landing inside the outage fails after the client's short retry window.
 Seen here as the runner's heartbeat being refused for a few seconds; it
 Seen here as the runner's heartbeat being refused for a few seconds; it
 recovered by itself, exactly as it does during the nightly backup stop.
 recovered by itself, exactly as it does during the nightly backup stop.
 
 
+### 5b-3. Open after the 2.13.0 pre-release run (smartbotic-vectorapi, 2026-10-08)
+
+- **A row can grow past the gRPC send limit through `patch`.** Measured on the
+  scratch server with send = receive = 100 MB: insert 60 MiB, then patch +20,
+  +10, +10 MiB - every request small and accepted - and `get` then fails
+  `message_too_large`; the export names it `row_too_large`. Nothing at write
+  time compares the RESULTING row with what can be sent back. Fix: refuse a
+  write whose stored row would exceed the listener's send limit (less framing),
+  with a reason, before applying it.
+- **A large write can report `DeadlineExceeded` after it was applied**, and the
+  client then retries it (`writeRetries`). Seen on those patches: the client's
+  per-call deadline expired while the server completed the write. Harmless for
+  an idempotent patch, wrong for `increment` or an id-less insert. Options: a
+  deadline scaled by request size, not retrying `DEADLINE_EXCEEDED` for
+  non-idempotent writes, or a request id the server de-duplicates.
+
 ### 5b-2. Open after the v2.11.4 consumer feedback round
 ### 5b-2. Open after the v2.11.4 consumer feedback round
 
 
 Two reports from smartbotic-vectorapi produced v2.11.4. Left open, with reasons:
 Two reports from smartbotic-vectorapi produced v2.11.4. Left open, with reasons:

+ 8 - 1
docs/integration-guide.md

@@ -581,12 +581,19 @@ if (!sum.complete) { /* resume: exportCollection(..., sum.lastId, ...) */ }
   when vectors are asked of a collection with `vector_dimension` 0.
   when vectors are asked of a collection with `vector_dimension` 0.
 - `batchRows` (default 256) is clamped to 1024, never refused; batches are also
 - `batchRows` (default 256) is clamped to 1024, never refused; batches are also
   cut at 8 MB (or half the server's send limit, if lower). The clamp is in
   cut at 8 MB (or half the server's send limit, if lower). The clamp is in
-  `header.batchRowsEffective`.
+  `header.batchRowsCap` - a cap, not a count: with large rows the real batches
+  are smaller, which the callback API never shows.
 - **A row too large for any one message** (bigger than the server's
 - **A row too large for any one message** (bigger than the server's
   `max_send_message_size_mb`) is never skipped silently: the export throws
   `max_send_message_size_mb`) is never skipped silently: the export throws
   `ResourceExhausted` with reason `row_too_large` and the row's id in
   `ResourceExhausted` with reason `row_too_large` and the row's id in
   `errorDetail(e)->conflictingId`. The rows before it were delivered; resume with
   `errorDetail(e)->conflictingId`. The rows before it were delivered; resume with
   `afterId` = that id to continue without it, deliberately.
   `afterId` = that id to continue without it, deliberately.
+- **Any call refused for size by gRPC itself** ("message larger than max",
+  either direction) throws `ResourceExhausted` with reason `message_too_large`
+  (2.13.0+), so it can be told from a rate limit or memory pressure, which share
+  the code: retrying never shrinks a payload. ⚠ A row can reach that size
+  without any single request doing so - repeated `patch` calls grow it - and is
+  then unreadable by `get`; split such data or store it as a file.
 
 
 **`vectorState`**, reported as stored and never guessed by the library:
 **`vectorState`**, reported as stored and never guessed by the library:
 
 

+ 1 - 1
proto/database.proto

@@ -557,7 +557,7 @@ message ExportHeader {
     uint32 vector_dimension = 2;
     uint32 vector_dimension = 2;
     string vector_dtype = 3;      // "float32-le"
     string vector_dtype = 3;      // "float32-le"
     uint64 rows_at_snapshot = 4;
     uint64 rows_at_snapshot = 4;
-    uint32 batch_rows_effective = 5;
+    uint32 batch_rows_cap = 5;     // the most rows a batch holds (requested, clamped); a batch also closes at 8 MB, so it may hold fewer
     uint32 max_stream_seconds = 6;
     uint32 max_stream_seconds = 6;
 }
 }
 
 

+ 1 - 1
service/src/database_grpc_impl.cpp

@@ -1956,7 +1956,7 @@ grpc::Status DatabaseGrpcImpl::ExportCollection(
                 h->set_vector_dimension(dimension);
                 h->set_vector_dimension(dimension);
                 h->set_vector_dtype("float32-le");
                 h->set_vector_dtype("float32-le");
                 h->set_rows_at_snapshot(rows);
                 h->set_rows_at_snapshot(rows);
-                h->set_batch_rows_effective(batchRows);
+                h->set_batch_rows_cap(batchRows);
                 h->set_max_stream_seconds(kExportMaxStreamSeconds);
                 h->set_max_stream_seconds(kExportMaxStreamSeconds);
                 if (!writer->Write(head)) writeFailed = true;
                 if (!writer->Write(head)) writeFailed = true;
             },
             },

+ 13 - 1
tests/load_test/test_export.cpp

@@ -161,7 +161,7 @@ static void check() {
     const uint64_t total = 400 + 40 + 20 + 20 + 1;
     const uint64_t total = 400 + 40 + 20 + 20 + 1;
     ck(e.header.vectorDimension == kDim, "header: dimension");
     ck(e.header.vectorDimension == kDim, "header: dimension");
     ck(e.header.vectorDtype == "float32-le", "header: dtype");
     ck(e.header.vectorDtype == "float32-le", "header: dtype");
-    ck(e.header.batchRowsEffective == 1024, "header: batch_rows 100000 clamped to 1024");
+    ck(e.header.batchRowsCap == 1024, "header: batch_rows 100000 clamped to 1024");
     ck(e.header.maxStreamSeconds == 600, "header: stream cap");
     ck(e.header.maxStreamSeconds == 600, "header: stream cap");
     ck(e.header.rowsAtSnapshot == total, "header: rows at snapshot");
     ck(e.header.rowsAtSnapshot == total, "header: rows at snapshot");
     ck(e.summary.complete && e.summary.rowsSent == total && e.rows.size() == total,
     ck(e.summary.complete && e.summary.rowsSent == total && e.rows.size() == total,
@@ -278,6 +278,18 @@ static void check() {
        "a row no message can carry: ResourceExhausted, row_too_large, naming b1 (got " +
        "a row no message can carry: ResourceExhausted, row_too_large, naming b1 (got " +
        std::to_string(int(bigCode)) + " " + bigReason + " " + bigId + ")");
        std::to_string(int(bigCode)) + " " + bigReason + " " + bigId + ")");
     ck(bigRows.size() == 1 && bigRows[0].id == "b0", "the rows before it were delivered");
     ck(bigRows.size() == 1 && bigRows[0].id == "b0", "the rows before it were delivered");
+    // gRPC refuses to SEND the 3 MB row for get() too, before our code runs;
+    // the client names that refusal so it is not mistaken for a rate limit.
+    std::string sizeReason;
+    Client::ErrorCode sizeCode = Client::ErrorCode::Ok;
+    try { (void)c.get("big", "b1"); }
+    catch (const Client::Error& err) {
+        sizeCode = err.code();
+        if (auto* d = Client::errorDetail(err)) sizeReason = d->reason;
+    }
+    ck(sizeCode == Client::ErrorCode::ResourceExhausted && sizeReason == "message_too_large",
+       "a get too large to send: ResourceExhausted, reason message_too_large (got " +
+       std::to_string(int(sizeCode)) + " '" + sizeReason + "')");
     auto afterBig = runExport(c, "big", false, "b1");
     auto afterBig = runExport(c, "big", false, "b1");
     ck(afterBig.summary.complete && afterBig.rows.size() == 1 && afterBig.rows[0].id == "b2",
     ck(afterBig.summary.complete && afterBig.rows.size() == 1 && afterBig.rows[0].id == "b2",
        "resuming after the named row completes the rest");
        "resuming after the named row completes the rest");

Некоторые файлы не были показаны из-за большого количества измененных файлов