mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 01:56:12 +01:00
Only run the DDL for session storage on the primary instance. (#6788)
This fixes a restart loop caused by deadlocks in large clusters.
This commit is contained in:
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();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user