mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[bug] Add 'updatePresence' to fix closed and restored connection 'addPresence' conflict in the cluster (with delaying disconnect event)
This commit is contained in:
@ -212,7 +212,7 @@
|
||||
"forcesave": 604800,
|
||||
"forcesaveLock": 5000,
|
||||
"saved": 3600,
|
||||
"documentsCron": "0 */2 * * * *",
|
||||
"documentsCron": "*/20 * * * * *",
|
||||
"files": 86400,
|
||||
"filesCron": "00 00 */1 * * *",
|
||||
"filesremovedatonce": 100,
|
||||
|
||||
@ -472,6 +472,14 @@ function addPresence(ctx, conn, updateCunters) {
|
||||
}
|
||||
});
|
||||
}
|
||||
async function updatePresence(ctx, conn) {
|
||||
if (editorData.updatePresence) {
|
||||
return await editorData.updatePresence(ctx, conn.docId, conn.user.id);
|
||||
} else {
|
||||
//todo remove if after 7.6. code for backward compatibility, because redis in separate repo
|
||||
return await editorData.addPresence(ctx, conn.docId, conn.user.id, utils.getConnectionInfoStr(conn));
|
||||
}
|
||||
}
|
||||
function removePresence(ctx, conn) {
|
||||
return co(function* () {
|
||||
yield editorData.removePresence(ctx, conn.docId, conn.user.id);
|
||||
@ -1732,6 +1740,7 @@ exports.install = function(server, callbackFunction) {
|
||||
const tenTokenEnableBrowser = ctx.getCfg('services.CoAuthoring.token.enable.browser', cfgTokenEnableBrowser);
|
||||
const tenForgottenFiles = ctx.getCfg('services.CoAuthoring.server.forgottenfiles', cfgForgottenFiles);
|
||||
|
||||
ctx.logger.info("Connection closed or timed out: reason = %s", reason);
|
||||
var userLocks, reconnected = false, bHasEditors, bHasChanges;
|
||||
var docId = conn.docId;
|
||||
if (null == docId) {
|
||||
@ -1741,7 +1750,7 @@ exports.install = function(server, callbackFunction) {
|
||||
let participantsTimestamp;
|
||||
var tmpUser = conn.user;
|
||||
var isView = tmpUser.view;
|
||||
ctx.logger.info("Connection closed or timed out: reason = %s", reason);
|
||||
|
||||
var isCloseCoAuthoringTmp = conn.isCloseCoAuthoring;
|
||||
if (reason) {
|
||||
//Notify that participant has gone
|
||||
@ -3808,7 +3817,7 @@ exports.install = function(server, callbackFunction) {
|
||||
if (constants.CONN_CLOSED === conn.conn.readyState) {
|
||||
ctx.logger.error('expireDoc connection closed');
|
||||
}
|
||||
yield addPresence(ctx, conn, false);
|
||||
yield updatePresence(ctx, conn);
|
||||
if (utils.isLiveViewer(conn)) {
|
||||
countLiveViewByShard++;
|
||||
tenant.countLiveViewByShard++;
|
||||
|
||||
@ -277,7 +277,7 @@ exports.getExpired = baseConnector.getExpired ?? function(ctx, maxCount, expireS
|
||||
utils.addSeconds(expireDate, -expireSeconds);
|
||||
const date = addSqlParam(expireDate, values);
|
||||
const count = addSqlParam(maxCount, values);
|
||||
const sqlCommand = `SELECT * FROM ${cfgTableResult} WHERE last_open_date <= ${date}` +
|
||||
const sqlCommand = `SELECT tenant, id FROM ${cfgTableResult} WHERE last_open_date <= ${date}` +
|
||||
` AND NOT EXISTS(SELECT tenant, id FROM ${cfgTableChanges} WHERE ${cfgTableChanges}.tenant = ${cfgTableResult}.tenant AND ${cfgTableChanges}.id = ${cfgTableResult}.id LIMIT 1) LIMIT ${count};`;
|
||||
baseConnector.sqlQuery(ctx, sqlCommand, function(error, result) {
|
||||
if (error) {
|
||||
|
||||
@ -96,6 +96,9 @@ EditorData.prototype._checkAndUnlock = function(ctx, name, docId, fencingToken)
|
||||
EditorData.prototype.addPresence = function(ctx, docId, userId, userInfo) {
|
||||
return Promise.resolve();
|
||||
};
|
||||
EditorData.prototype.updatePresence = function(ctx, docId, userId) {
|
||||
return Promise.resolve();
|
||||
};
|
||||
EditorData.prototype.removePresence = function(ctx, docId, userId) {
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
@ -67,7 +67,7 @@ const cfgTokenEnableRequestOutbox = config.get('services.CoAuthoring.token.enabl
|
||||
const cfgLicenseFile = config.get('license.license_file');
|
||||
const cfgDownloadMaxBytes = config.get('FileConverter.converter.maxDownloadBytes');
|
||||
|
||||
if (false) {
|
||||
if (true) {
|
||||
var cluster = require('cluster');
|
||||
cluster.schedulingPolicy = cluster.SCHED_RR
|
||||
if (cluster.isMaster) {
|
||||
|
||||
Reference in New Issue
Block a user