Hello, I noticed a problem with lmdb attempting to flush something to the disk, even when used with { readOnly: true } option. This is making it challenging to use it with AWS lambda which has read-only root file system.
Steps to reproduce
Make a simple db using code from README.md
import { open } from 'lmdb'; // or require
let myDB = open({
path: './db.lmdb',
});
await myDB.put('greeting', { someText: 'Hello, World!' });
A test script, test.js
const lmdb = require('lmdb');
const db = lmdb.open('./db.lmdb', {
readOnly: true,
noSync: true,
});
const res = db.get('greeting');
console.log(res);
Make a Dockerfile:
FROM public.ecr.aws/lambda/nodejs:20
RUN npm i lmdb
COPY test.js .
COPY db.lmdb .
COPY db.lmdb-lock .
ENTRYPOINT [ "node", "test.js" ]
Build
docker build -t lmdb .
Run (with writable root fs - default)
docker run lmdb
output:
{ someText: 'Hello, World!' }
Run in read only mode
docker run --read-only lmdb
output:
/var/task/node_modules/lmdb/dist/index.cjs:2626
let rc = env.open(options, flags, jsFlags);
^
Error: Read-only file system
at Object.open (/var/task/node_modules/lmdb/dist/index.cjs:2626:15)
at Object.<anonymous> (/var/task/test.js:3:17)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
code: 30
}
Hello, I noticed a problem with lmdb attempting to flush something to the disk, even when used with
{ readOnly: true }
option. This is making it challenging to use it with AWS lambda which has read-only root file system.Steps to reproduce
test.js
Dockerfile
:output:
output: