fix(native): possible deadlock when batching read/write (#9817)

This commit is contained in:
forehalo
2025-01-21 06:07:03 +00:00
parent 46ee235674
commit 07c32d016d
11 changed files with 208 additions and 169 deletions
@@ -0,0 +1,31 @@
import { DocStoragePool } from '../index';
import test from 'ava';
test('can batch read/write pool', async t => {
const pool = new DocStoragePool();
await pool.connect('test', ':memory:');
const batch = 512;
await Promise.all(
Array.from({ length: batch }).map(async (_, i) => {
return pool.setBlob('test', {
key: `test-blob-${i}`,
data: new Uint8Array([i % 255]),
mime: 'text/plain',
});
})
);
const blobs = await Promise.all(
Array.from({ length: batch }).map(async (_, i) => {
return pool.getBlob('test', `test-blob-${i}`);
})
);
t.is(blobs.length, batch);
t.is(
blobs.every((blob, i) => blob!.data.at(0) === i % 255),
true
);
});