Skip to content

Commit

Permalink
Properly assign overflow page number on compact backup
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Mar 1, 2024
1 parent c08e030 commit dd08273
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dependencies/lmdb/libraries/liblmdb/mdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -11577,7 +11577,7 @@ mdb_env_cwalk(mdb_copy *my, pgno_t *pg, int flags)
}
mo = (MDB_page *)(my->mc_wbuf[toggle] + my->mc_wlen[toggle]);
memcpy(mo, omp, my->mc_env->me_psize);
ovp.op_pgno = my->mc_next_pgno;
ovp.op_pgno = mo->mp_pgno = my->mc_next_pgno;
ovp.op_txnid = 1;
memcpy(NODEDATA(ni), &ovp, sizeof(ovp));
my->mc_next_pgno += ovp.op_pages;
Expand Down
2 changes: 1 addition & 1 deletion open.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export function open(path, options) {
if (noFSAccess)
return;
fs.mkdirSync(pathModule.dirname(path), { recursive: true });
return new Promise((resolve, reject) => env.copy(path, false, (error) => {
return new Promise((resolve, reject) => env.copy(path, compact, (error) => {
if (error) {
reject(error);
} else {
Expand Down
8 changes: 2 additions & 6 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ describe('lmdb-js', function () {
});
should.equal(dbRAS.get(3).name, 'three');
});
it.skip('can backup and use backup', async function () {
it('can backup and use backup', async function () {
if (options.encryptionKey)
// it won't match the environment
return;
Expand All @@ -1764,14 +1764,10 @@ describe('lmdb-js', function () {
let backupDb = open(testDirPath + '/backup.mdb', options);
try {
backupDb.get('for-backup-110').should.equal(value.slice(0, 5500));
value += ' changed';
for (let i = 0; i < 100; i++) {
const testGet = backupDb.get('for-backup-5');
console.log('testGetSize', testGet.length);
console.log('writing on backup file',i);
await backupDb.put('for-backup-' + i, 'test');
}
backupDb.get('for-backup-1').should.equal(value);
backupDb.get('for-backup-1').should.equal('test');
} finally {
await backupDb.close();
}
Expand Down

0 comments on commit dd08273

Please sign in to comment.