Only run the DDL for session storage on the primary instance. (#6788)

This fixes a restart loop caused by deadlocks in large clusters.
v1.18.x
Ben Lubar 6 years ago committed by Barış Soner Uşaklı
parent 3d13d867cb
commit 11b655163e

@ -364,6 +364,21 @@ postgresModule.initSessionStore = function (callback) {
return callback();
}
function done() {
sessionStore = require('connect-pg-simple')(session);
postgresModule.sessionStore = new sessionStore({
pool: db,
ttl: ttl,
pruneSessionInterval: nconf.get('isPrimary') === 'true' ? 60 : false,
});
callback();
}
if (nconf.get('isPrimary') !== 'true') {
return done();
}
db.query(`
CREATE TABLE IF NOT EXISTS "session" (
"sid" CHAR(32) NOT NULL
@ -382,14 +397,7 @@ ALTER TABLE "session"
return callback(err);
}
sessionStore = require('connect-pg-simple')(session);
postgresModule.sessionStore = new sessionStore({
pool: db,
ttl: ttl,
pruneSessionInterval: nconf.get('isPrimary') === 'true' ? 60 : false,
});
callback();
done();
});
};

Loading…
Cancel
Save