1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

feat(ext/kv): increase checks limit (#21055)

This commit is contained in:
Igor Zinkovsky 2023-11-02 11:57:11 -07:00 committed by GitHub
parent 41877a0b37
commit 1d0856a4f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View file

@ -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((

View file

@ -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 {