Mobrovac has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/393382 )
Change subject: Commit the last committed offset if no commit happened ...................................................................... Commit the last committed offset if no commit happened Bug: T181346 Change-Id: I8329ac6b52d0ee137d5259ac78aa9033bd3fa66c --- M lib/EventSource.js 1 file changed, 8 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/trending-edits refs/changes/82/393382/1 diff --git a/lib/EventSource.js b/lib/EventSource.js index 8ab8c06..5294ce0 100644 --- a/lib/EventSource.js +++ b/lib/EventSource.js @@ -108,12 +108,20 @@ }); }); this._commitQueue = []; + this._lastCommit = null; this._commitInterval = setInterval(() => { const cutoffDate = Date.now() - this._options.purge_strategy.max_age * 60 * 1000; + let committed = false; while (this._commitQueue.length && this._commitQueue[0].timestamp <= cutoffDate) { const commit = this._commitQueue.shift(); this._consumer.commit(commit.message); + this._lastCommit = commit.message; + committed = true; + } + if (!committed && this._lastCommit) { + // if we didn't commit anything, re-commit the last message + this._consumer.commit(this._lastCommit); } }, COMMIT_INTERVAL); } -- To view, visit https://gerrit.wikimedia.org/r/393382 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8329ac6b52d0ee137d5259ac78aa9033bd3fa66c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/trending-edits Gerrit-Branch: master Gerrit-Owner: Mobrovac <mobro...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits