WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a1b137c

Browse files
authored
Merge pull request #18011 from mozilla/inactive-uids-concurrency
chore(script): add concurrency to inactive uids script
2 parents 616c182 + 4b7d223 commit a1b137c

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

packages/fxa-auth-server/scripts/delete-inactive-accounts/get-inactive-account-uids.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { performance } from 'perf_hooks';
1818
import { Command } from 'commander';
1919
import { StatsD } from 'hot-shots';
2020
import { Container } from 'typedi';
21+
import PQueue from 'p-queue-compat';
2122

2223
import { parseDryRun } from '../lib/args';
2324
import { AppConfig, AuthFirestore, AuthLogger } from '../../lib/types';
@@ -107,6 +108,11 @@ const init = async () => {
107108
'The number of results per accounts DB query. Defaults to 100000.',
108109
parseInt
109110
)
111+
.option(
112+
'--concurrency [number]',
113+
'The number inflight active checks. Defaults to 6.',
114+
parseInt
115+
)
110116
.option('--perf-stats [true|false]', 'Print out performance stats.', false);
111117

112118
program.parse(process.argv);
@@ -253,6 +259,10 @@ const init = async () => {
253259
}
254260

255261
const fd = fs.openSync(filepath, 'a');
262+
const concurrency = program.concurrency || 6;
263+
const queue = new PQueue({
264+
concurrency,
265+
});
256266

257267
let hasMaxResultsCount = true;
258268
let totalRowsReturned = 0;
@@ -271,10 +281,15 @@ const init = async () => {
271281

272282
const inactiveUids: string[] = [];
273283
for (const accountRecord of accounts) {
274-
if (!(await isActive(accountRecord))) {
275-
inactiveUids.push(accountRecord.uid);
276-
}
284+
await queue.onSizeLessThan(concurrency * 5);
285+
286+
queue.add(async () => {
287+
if (!(await isActive(accountRecord))) {
288+
inactiveUids.push(accountRecord.uid);
289+
}
290+
});
277291
}
292+
await queue.onIdle();
278293

279294
if (inactiveUids.length) {
280295
totalInactiveAccounts += inactiveUids.length;

0 commit comments

Comments
 (0)