GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sqlite: retry busy or locked backup steps · nodejs/node@fd7dc86

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_sqlite.cc
  • test/parallel
    • test-sqlite-backup.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_sqlite.cc‎

Copy file name to clipboardExpand all lines: src/node_sqlite.cc
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ class BackupJob : public ThreadPoolWork {
680680
return;
681681
}
682682

683+
if (backup_status_ == SQLITE_BUSY || backup_status_ == SQLITE_LOCKED) {
684+
this->ScheduleWork();
685+
return;
686+
}
687+
683688
int total_pages = sqlite3_backup_pagecount(backup_.get());
684689
int remaining_pages = sqlite3_backup_remaining(backup_.get());
685690
if (remaining_pages != 0) {
Collapse file

‎test/parallel/test-sqlite-backup.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-sqlite-backup.mjs
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Flags: --expose-gc
22
import {
33
isWindows,
4+
platformTimeout,
45
skipIfSQLiteMissing,
56
spawnPromisified,
67
} from '../common/index.mjs';
@@ -351,6 +352,32 @@ test('backup fails when path cannot be opened', async (t) => {
351352
});
352353
});
353354

355+
test('backup waits for a write transaction on the source to end', async (t) => {
356+
const database = makeSourceDb();
357+
const destDb = nextDb();
358+
359+
t.after(() => { database.close(); });
360+
361+
database.exec('BEGIN IMMEDIATE');
362+
database.exec("INSERT INTO data (key, value) VALUES (3, 'value-3')");
363+
const p = backup(database, destDb);
364+
setTimeout(() => database.exec('COMMIT'), platformTimeout(100));
365+
366+
await p;
367+
368+
const backupDb = new Database(destDb);
369+
370+
t.after(() => { backupDb.close(); });
371+
372+
const rows = backupDb.prepare('SELECT * FROM data').all();
373+
374+
t.assert.deepStrictEqual(rows, [
375+
{ __proto__: null, key: 1, value: 'value-1' },
376+
{ __proto__: null, key: 2, value: 'value-2' },
377+
{ __proto__: null, key: 3, value: 'value-3' },
378+
]);
379+
});
380+
354381
test('backup has correct name and length', (t) => {
355382
t.assert.strictEqual(backup.name, 'backup');
356383
t.assert.strictEqual(backup.length, 2);

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.