Skip to content

Commit 67afa78

Browse files
committed
hot patch mem spam issue
1 parent 632f277 commit 67afa78

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/coinstac-pipeline/src/pipeline-manager.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ module.exports = {
7474
* @return {Promise} Promise on completion
7575
*/
7676
const cleanupPipeline = (runId) => {
77+
activePipelines[runId].cleanupInterval();
7778
return Promise.all([
7879
rmrf(path.resolve(activePipelines[runId].transferDirectory)),
7980
rmrf(path.resolve(activePipelines[runId].systemDirectory)),
@@ -166,10 +167,6 @@ module.exports = {
166167
transferDirectory: path.resolve(operatingDirectory, 'transfer', clientId, runId),
167168
};
168169

169-
const intervalCleanupRegistry = new FinalizationRegistry((intervalId) => {
170-
clearInterval(intervalId);
171-
});
172-
173170
activePipelines[runId] = Object.assign(
174171
{
175172
state: 'created',
@@ -197,6 +194,7 @@ module.exports = {
197194
owner: spec.owner,
198195
limitOutputToOwner: spec.limitOutputToOwner,
199196
debug: {},
197+
cleanupInterval() {},
200198
},
201199
activePipelines[runId],
202200
saveState ? saveState.activePipeline : {}
@@ -205,7 +203,6 @@ module.exports = {
205203
activePipelines[runId].maxMemoryUsage = (() => {
206204
let currentMaxMem = {max: 0, string: '' };
207205

208-
// Start an interval to update `currentMaxMem`
209206
const intervalId = setInterval(async () => {
210207
let containerStats = await containerManager.getStats(runId, clientId)
211208
if (containerStats) {
@@ -215,9 +212,9 @@ module.exports = {
215212
}
216213
}, 1000);
217214

218-
// Register the interval for cleanup when the object is garbage collected
219-
intervalCleanupRegistry.register(activePipelines[runId], intervalId);
220-
215+
activePipelines[runId].cleanupInterval = function () {
216+
clearInterval(intervalId);
217+
};
221218
// Return the getter function
222219
return () => currentMaxMem;
223220
})();
@@ -310,7 +307,9 @@ module.exports = {
310307
});
311308
debugProfile(`Total pipeline time: ${totalTime}ms`);
312309
}
310+
313311
if (!activePipelines[runId].finalTransferList
312+
|| activePipelines[runId].finalTransferList.size === 0
314313
|| Object.keys(activePipelines[runId].clients)
315314
.every(clientId => activePipelines[runId].finalTransferList.has(clientId))
316315
|| (

0 commit comments

Comments
 (0)