mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +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();
|
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(`
|
db.query(`
|
||||||
CREATE TABLE IF NOT EXISTS "session" (
|
CREATE TABLE IF NOT EXISTS "session" (
|
||||||
"sid" CHAR(32) NOT NULL
|
"sid" CHAR(32) NOT NULL
|
||||||
@@ -382,14 +397,7 @@ ALTER TABLE "session"
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionStore = require('connect-pg-simple')(session);
|
done();
|
||||||
postgresModule.sessionStore = new sessionStore({
|
|
||||||
pool: db,
|
|
||||||
ttl: ttl,
|
|
||||||
pruneSessionInterval: nconf.get('isPrimary') === 'true' ? 60 : false,
|
|
||||||
});
|
|
||||||
|
|
||||||
callback();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user