Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Commit

Permalink
force WAL checkpoint after every write
Browse files Browse the repository at this point in the history
  • Loading branch information
askmike committed Jun 30, 2018
1 parent 46c984f commit 58cdeb4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/sqlite/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ Store.prototype.upsertTables = function() {
}

Store.prototype.writeCandles = function() {
console.log(this.cache);
if(_.isEmpty(this.cache))
return;

var transaction = function() {
const transaction = () => {
this.db.run("BEGIN TRANSACTION");

var stmt = this.db.prepare(`
Expand Down Expand Up @@ -81,11 +82,13 @@ Store.prototype.writeCandles = function() {

stmt.finalize();
this.db.run("COMMIT");
// TEMP: should fix https://forum.gekko.wizb.it/thread-57279-post-59194.html#pid59194
this.db.run("pragma wal_checkpoint;");

this.cache = [];
}

this.db.serialize(_.bind(transaction, this));
this.db.serialize(transaction);
}

var processCandle = function(candle, done) {
Expand Down

0 comments on commit 58cdeb4

Please sign in to comment.