summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit/kv_test.ts8
-rw-r--r--ext/kv/lib.rs15
2 files changed, 15 insertions, 8 deletions
diff --git a/cli/tests/unit/kv_test.ts b/cli/tests/unit/kv_test.ts
index 0bfc75481..1677dd990 100644
--- a/cli/tests/unit/kv_test.ts
+++ b/cli/tests/unit/kv_test.ts
@@ -1165,6 +1165,10 @@ dbTest("operation size limit", async (db) => {
_,
i,
) => ["a", i]);
+ const invalidCheckKeys: Deno.KvKey[] = new Array(101).fill(0).map((
+ _,
+ i,
+ ) => ["a", i]);
const res = await db.getMany(lastValidKeys);
assertEquals(res.length, 10);
@@ -1206,7 +1210,7 @@ dbTest("operation size limit", async (db) => {
await assertRejects(
async () => {
await db.atomic()
- .check(...firstInvalidKeys.map((key) => ({
+ .check(...invalidCheckKeys.map((key) => ({
key,
versionstamp: null,
})))
@@ -1218,7 +1222,7 @@ dbTest("operation size limit", async (db) => {
.commit();
},
TypeError,
- "too many checks (max 10)",
+ "too many checks (max 100)",
);
const validMutateKeys: Deno.KvKey[] = new Array(1000).fill(0).map((
diff --git a/ext/kv/lib.rs b/ext/kv/lib.rs
index d357a2927..c0091d75d 100644
--- a/ext/kv/lib.rs
+++ b/ext/kv/lib.rs
@@ -60,7 +60,7 @@ const MAX_READ_KEY_SIZE_BYTES: usize = MAX_WRITE_KEY_SIZE_BYTES + 1;
const MAX_VALUE_SIZE_BYTES: usize = 65536;
const MAX_READ_RANGES: usize = 10;
const MAX_READ_ENTRIES: usize = 1000;
-const MAX_CHECKS: usize = 10;
+const MAX_CHECKS: usize = 100;
const MAX_MUTATIONS: usize = 1000;
const MAX_TOTAL_MUTATION_SIZE_BYTES: usize = 800 * 1024;
const MAX_TOTAL_KEY_SIZE_BYTES: usize = 80 * 1024;
@@ -669,13 +669,16 @@ where
return Err(type_error("key cannot be empty"));
}
- let checked_size = check_write_key_size(key)?;
- total_payload_size += checked_size;
- total_key_size += checked_size;
+ total_payload_size += check_write_key_size(key)?;
}
- for value in mutations.iter().flat_map(|m| m.kind.value()) {
- total_payload_size += check_value_size(value)?;
+ for (key, value) in mutations
+ .iter()
+ .flat_map(|m| m.kind.value().map(|x| (&m.key, x)))
+ {
+ let key_size = check_write_key_size(key)?;
+ total_payload_size += check_value_size(value)? + key_size;
+ total_key_size += key_size;
}
for enqueue in &enqueues {