Skip to content

Commit ff19f3c

Browse files
[feature] Filter old rows in getCountWithStatus while "shutdown"
1 parent 8db8839 commit ff19f3c

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

DocService/sources/databaseConnectors/baseConnector.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,13 @@ function getExpired(ctx, maxCount, expireSeconds) {
297297
}, false, false, values);
298298
});
299299
}
300-
function getCountWithStatus(ctx, status) {
300+
function getCountWithStatus(ctx, status, expireMs) {
301301
return new Promise(function(resolve, reject) {
302302
const values = [];
303-
const sqlParam = addSqlParameter(status, values);
304-
const sqlCommand = `SELECT COUNT(id) AS count FROM ${cfgTableResult} WHERE status=${sqlParam};`;
303+
const expireDate = new Date(Date.now() - expireMs);
304+
const sqlStatus = addSqlParameter(status, values);
305+
const sqlDate = addSqlParameter(expireDate, values);
306+
const sqlCommand = `SELECT COUNT(id) AS count FROM ${cfgTableResult} WHERE status=${sqlStatus} AND last_open_date>${sqlDate};`;
305307
dbInstance.sqlQuery(ctx, sqlCommand, function(error, result) {
306308
if (error) {
307309
reject(error);

DocService/sources/shutdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ exports.shutdown = function(ctx, editorStat, status) {
7878
break;
7979
}
8080
var remainingFiles = yield editorStat.getShutdownCount(redisKeyShutdown);
81-
let inSavingStatus = yield sqlBase.getCountWithStatus(ctx, commonDefines.FileStatus.SaveVersion);
81+
let inSavingStatus = yield sqlBase.getCountWithStatus(ctx, commonDefines.FileStatus.SaveVersion, EXEC_TIMEOUT);
8282
ctx.logger.debug('shutdown remaining files editorStat:%d, db:%d', remainingFiles, inSavingStatus);
8383
if (!isStartWait && (remainingFiles + inSavingStatus) <= 0) {
8484
break;

0 commit comments

Comments
 (0)