diff --git a/lib/eviction.js b/lib/eviction.js index 41cc79b88..0af01767e 100644 --- a/lib/eviction.js +++ b/lib/eviction.js @@ -5,6 +5,7 @@ var nThen = require("nthen"); var Bloom = require("@mcrowe/minibloom"); var Util = require("../lib/common-util"); +var Linked = require("../lib/commands/linked"); var Pins = require("../lib/pins"); var Keys = require("./keys"); var Path = require('node:path'); @@ -379,10 +380,21 @@ module.exports = function (Env, cb) { accountRetentionTime = -1; } - var pinAll = function (pinList) { + var pinAll = function (pinList, cb) { + let n = nThen; pinList.forEach(function (docId) { pinnedDocs.add(docId); + + // Add linked documents + if (docId.length !== 32) { return; } + n = n(w => { + Linked.listLinkedDocuments(Env, docId, w((err, channels) => { + if (!Array.isArray(channels)) { return; } + channels.forEach(chan => { pinnedDocs.add(chan); }); + })); + }).nThen; }); + n(() => { cb(); }); }; var docIsActive = function (docId) { @@ -422,8 +434,7 @@ module.exports = function (Env, cb) { if (accountIsActive(mtime, pinList)) { // add active accounts' pinned documents to a second bloom filter - pinAll(pinList); - return void next(); + return pinAll(pinList, next); } // Otherwise they are inactive. @@ -431,19 +442,21 @@ module.exports = function (Env, cb) { // we plan to delete them, because it may be interesting information inactive++; if (PRESERVE_INACTIVE_ACCOUNTS) { - pinAll(pinList); - return Log.info('EVICT_INACTIVE_ACCOUNT_PRESERVED', { - id: id, - mtime: mtime, - }, next); + return pinAll(pinList, () => { + Log.info('EVICT_INACTIVE_ACCOUNT_PRESERVED', { + id: id, + mtime: mtime, + }, next); + }); } if (isPremiumAccount(id)) { - pinAll(pinList); - return Log.info("EVICT_INACTIVE_PREMIUM_ACCOUNT", { - id: id, - mtime: mtime, - }, next); + return pinAll(pinList, () => { + Log.info("EVICT_INACTIVE_PREMIUM_ACCOUNT", { + id: id, + mtime: mtime, + }, next); + }); } // remove the pin logs of inactive accounts if inactive account removal is configured