Skip to content

Commit 2bbd7a2

Browse files
committed
enable running db checkpoints before loads
1 parent 7c9b9ed commit 2bbd7a2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/run-configuration.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const generateFromArgs = (args) => {
131131
const obj = _.merge({
132132
generator: schema ? new MockData(schema) : null,
133133
batchSize,
134+
runcheckpoint: args.runcheckpoint,
134135
checkpointFreq: args.checkpoint || process.env.CHECKPOINT_FREQUENCY || 5000,
135136
failFast,
136137
phase: 'NOT_STARTED',
@@ -158,6 +159,7 @@ module.exports = {
158159
.describe('u', 'username')
159160
.describe('p', 'password')
160161
.describe('d', 'database')
162+
.describe('runcheckpoint', 'whether to run db checkpointing or not')
161163
.describe('schema', 'batch schema file')
162164
.describe('batchsize', 'number of records per batch, usable only with schema')
163165
.describe('n', 'number of hits on the database')
@@ -166,6 +168,7 @@ module.exports = {
166168
.describe('query', 'Cypher query to run')
167169
.default('concurrency', 10)
168170
.default('checkpoint', 5000)
171+
.default('runcheckpoint', false)
169172
.demandOption(['p'])
170173
.argv;
171174
},

src/workload.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,19 @@ class Workload {
7676
const runStrategySetupPromises = Object.keys(this.strategyTable)
7777
.map(stratName => this.strategyTable[stratName].setup(this.driver));
7878

79-
return Promise.all(runStrategySetupPromises);
79+
return Promise.all(runStrategySetupPromises)
80+
.then(results => {
81+
if (this.runConfig.runcheckpoint) {
82+
const opts = {};
83+
if (this.runConfig.database) { opts.database = this.runConfig.database; }
84+
const session = this.driver.session(opts);
85+
console.log('Calling db.checkpoint method to flush prior to run');
86+
return session.run('CALL db.checkpoint()')
87+
.then(session.close);
88+
}
89+
90+
return results;
91+
});
8092
}
8193

8294
getRunConfiguration() { return this.runConfig; }

0 commit comments

Comments
 (0)