-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Value of size 333MB fails to be fetched from the DB #205
Comments
In my tests, I was able to get values up to 2gb. What error are you seeing? |
I'm seeing:
|
This is a small demo (it fails on Ubuntu 20, lmdb-js v2.7.3) with a segfault.
/* eslint-disable */
import { open } from 'lmdb';
import * as fs from 'fs';
async function main() {
const db = open<any, string>({
path: `./test-cache`,
});
const big = fs.readFileSync("./bigfile.bin")
await db.put("id", big.toString())
console.log("put() success")
let loaded = await db.getBinary("id")
console.log("getBinary() success")
loaded = await db.getBinaryFast("id")
console.log("getBinaryFast() success")
loaded = await db.get("id")
console.log("get() success")
await db.close()
console.log("OK")
}
main().catch((e) => console.error(e)); If you create a smaller file and run it it prints OK: |
I am kind of wondering if this is a V8 bug. I can actually trigger an error without lmdb at all by doing this with your code:
I think this error might be occurring in the msgpackr's native decoder and might not be properly handled there, but even if it was, V8 doesn't seem to be capable of decoding this string. |
Maybe there should be an option for |
Yes, @janekolszak, that seems like a reasonable option to add. I will try to get that in the next release. |
Maybe lmdb-js decodes values into strings? There seems to be a limit of 512MB for string size on 32b systems, but I see it on my 64b system with node 19.3.0 Your demo on node 18.12.1 fails with:
Your demo on node 19.3.0 fails with:
My demo on node 18.12.1 fails with:
My demo on node 19.3.0 fails with:
Your demo modified for Deno:
|
lmdb-js (msgpackr) preserves the types of values, so if you encode a string, it will be decoded as a string. And you are explicitly converting your data to a string when it is stored/encoded (so lmdb-js decodes to a string to match what you requested/stored): (so if you don't want it decoded as a string, don't store it as a string, store it as a buffer/binary data)
It doesn't seem that surprising that V8 would change this without MDN being updated yet (maybe they felt it was better to be consistent so that there is no behavioral differences that can be observed/detected between architectures). |
Hi!
Is it expected that it's not possible to
get()
values bigger than 333MB?It is possible to fetch with
getBinary()
.Thank you!
The text was updated successfully, but these errors were encountered: