diff --git a/services/history-v1/storage/scripts/back_fill_file_hash.mjs b/services/history-v1/storage/scripts/back_fill_file_hash.mjs index 15c9e8508e..742e857ac4 100644 --- a/services/history-v1/storage/scripts/back_fill_file_hash.mjs +++ b/services/history-v1/storage/scripts/back_fill_file_hash.mjs @@ -1101,6 +1101,13 @@ try { await main() } finally { printStats() + try { + // Perform non-recursive removal of the BUFFER_DIR. Individual files + // should get removed in parallel as part of batch processing. + await fs.promises.rmdir(BUFFER_DIR) + } catch (err) { + console.error(`cleanup of BUFFER_DIR=${BUFFER_DIR} failed`, err) + } } let code = 0 diff --git a/services/history-v1/test/acceptance/js/storage/back_fill_file_hash.test.mjs b/services/history-v1/test/acceptance/js/storage/back_fill_file_hash.test.mjs index 6a2a4046f7..af75d3a871 100644 --- a/services/history-v1/test/acceptance/js/storage/back_fill_file_hash.test.mjs +++ b/services/history-v1/test/acceptance/js/storage/back_fill_file_hash.test.mjs @@ -1,3 +1,4 @@ +import fs from 'node:fs' import Crypto from 'node:crypto' import Stream from 'node:stream' import { setTimeout } from 'node:timers/promises' @@ -511,6 +512,9 @@ describe('back_fill_file_hash script', function () { } result = { stdout, stderr, status: code } } + expect((await fs.promises.readdir('/tmp')).join(';')).to.not.match( + /back_fill_file_hash/ + ) const extraStatsKeys = [ 'eventLoop', 'readFromGCSThroughputMiBPerSecond',