mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[feature] Filter old rows in getCountWithStatus while "shutdown"
This commit is contained in:
@ -297,11 +297,13 @@ function getExpired(ctx, maxCount, expireSeconds) {
|
||||
}, false, false, values);
|
||||
});
|
||||
}
|
||||
function getCountWithStatus(ctx, status) {
|
||||
function getCountWithStatus(ctx, status, expireMs) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
const values = [];
|
||||
const sqlParam = addSqlParameter(status, values);
|
||||
const sqlCommand = `SELECT COUNT(id) AS count FROM ${cfgTableResult} WHERE status=${sqlParam};`;
|
||||
const expireDate = new Date(Date.now() - expireMs);
|
||||
const sqlStatus = addSqlParameter(status, values);
|
||||
const sqlDate = addSqlParameter(expireDate, values);
|
||||
const sqlCommand = `SELECT COUNT(id) AS count FROM ${cfgTableResult} WHERE status=${sqlStatus} AND last_open_date>${sqlDate};`;
|
||||
dbInstance.sqlQuery(ctx, sqlCommand, function(error, result) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
|
||||
@ -78,7 +78,7 @@ exports.shutdown = function(ctx, editorStat, status) {
|
||||
break;
|
||||
}
|
||||
var remainingFiles = yield editorStat.getShutdownCount(redisKeyShutdown);
|
||||
let inSavingStatus = yield sqlBase.getCountWithStatus(ctx, commonDefines.FileStatus.SaveVersion);
|
||||
let inSavingStatus = yield sqlBase.getCountWithStatus(ctx, commonDefines.FileStatus.SaveVersion, EXEC_TIMEOUT);
|
||||
ctx.logger.debug('shutdown remaining files editorStat:%d, db:%d', remainingFiles, inSavingStatus);
|
||||
if (!isStartWait && (remainingFiles + inSavingStatus) <= 0) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user