mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Merge pull request #29891 from overleaf/bg-docupdater-make-max-unflushed-age-configurable
Make document-updater max unflushed age configurable via settings GitOrigin-RevId: 3421f2467b7d8459ba8cdb1859e1b0695b0a01f3
This commit is contained in:
@@ -13,7 +13,7 @@ const { getTotalSizeOfLines } = require('./Limits')
|
||||
const Settings = require('@overleaf/settings')
|
||||
const { StringFileData } = require('overleaf-editor-core')
|
||||
|
||||
const MAX_UNFLUSHED_AGE = 300 * 1000 // 5 mins, document should be flushed to mongo this time after a change
|
||||
const MAX_UNFLUSHED_AGE = Settings.maxUnflushedAgeMs // document should be flushed to mongo this time after a change
|
||||
|
||||
const DocumentManager = {
|
||||
/**
|
||||
|
||||
@@ -188,6 +188,9 @@ module.exports = {
|
||||
gracefulShutdownDelayInMs:
|
||||
parseInt(process.env.GRACEFUL_SHUTDOWN_DELAY_SECONDS ?? '10', 10) * 1000,
|
||||
|
||||
maxUnflushedAgeMs:
|
||||
parseInt(process.env.MAX_UNFLUSHED_AGE_SECONDS ?? '300', 10) * 1000, // 5 mins by default
|
||||
|
||||
shortHistoryQueues: (process.env.SHORT_HISTORY_QUEUES || '')
|
||||
.split(',')
|
||||
.filter(s => !!s),
|
||||
|
||||
@@ -58,6 +58,7 @@ describe('DocumentManager', function () {
|
||||
}
|
||||
this.Settings = {
|
||||
max_doc_length: 2 * 1024 * 1024, // 2mb
|
||||
maxUnflushedAgeMs: 300 * 1000, // 5 minutes
|
||||
}
|
||||
|
||||
this.DocumentManager = SandboxedModule.require(modulePath, {
|
||||
@@ -1030,7 +1031,7 @@ describe('DocumentManager', function () {
|
||||
ranges: this.ranges,
|
||||
projectHistoryId: this.projectHistoryId,
|
||||
pathname: this.pathname,
|
||||
unflushedTime: Date.now() - 1e9,
|
||||
unflushedTime: Date.now() - 2 * this.Settings.maxUnflushedAgeMs, // document is older than max unflushed age
|
||||
alreadyLoaded: true,
|
||||
})
|
||||
this.result = await this.DocumentManager.promises.getDocAndFlushIfOld(
|
||||
@@ -1066,7 +1067,7 @@ describe('DocumentManager', function () {
|
||||
version: this.version,
|
||||
ranges: this.ranges,
|
||||
pathname: this.pathname,
|
||||
unflushedTime: Date.now() - 100,
|
||||
unflushedTime: Date.now() - 0.5 * this.Settings.maxUnflushedAgeMs, // document is not old enough to trigger flush
|
||||
alreadyLoaded: true,
|
||||
})
|
||||
this.result = await this.DocumentManager.promises.getDocAndFlushIfOld(
|
||||
|
||||
Reference in New Issue
Block a user