From: Jérôme Benoit Date: Wed, 30 Aug 2023 11:42:13 +0000 (+0200) Subject: fix: fix IWRR worker node removal X-Git-Tag: v2.6.38~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d854790162e5f554fdda30b082d362fe14a9ac43;p=poolifier.git fix: fix IWRR worker node removal Signed-off-by: Jérôme Benoit --- diff --git a/package.json b/package.json index 1a34081f..c715874b 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "eslint-define-config": "^1.23.0", "eslint-import-resolver-typescript": "^3.6.0", "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jsdoc": "^46.5.0", + "eslint-plugin-jsdoc": "^46.5.1", "eslint-plugin-n": "^16.0.2", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-spellcheck": "^0.0.20", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cf114807..8464ed17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,8 +60,8 @@ devDependencies: specifier: ^2.28.1 version: 2.28.1(@typescript-eslint/parser@6.5.0)(eslint-import-resolver-typescript@3.6.0)(eslint@8.48.0) eslint-plugin-jsdoc: - specifier: ^46.5.0 - version: 46.5.0(eslint@8.48.0) + specifier: ^46.5.1 + version: 46.5.1(eslint@8.48.0) eslint-plugin-n: specifier: ^16.0.2 version: 16.0.2(eslint@8.48.0) @@ -417,8 +417,8 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@humanwhocodes/config-array@0.11.10: - resolution: {integrity: sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==} + /@humanwhocodes/config-array@0.11.11: + resolution: {integrity: sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==} engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 1.2.1 @@ -739,7 +739,7 @@ packages: rollup: 3.28.1 serialize-javascript: 6.0.1 smob: 1.4.0 - terser: 5.19.2 + terser: 5.19.3 dev: true /@rollup/plugin-typescript@11.1.3(rollup@3.28.1)(typescript@5.2.2): @@ -1402,8 +1402,8 @@ packages: engines: {node: '>=8'} dev: true - /array.prototype.findlastindex@1.2.2: - resolution: {integrity: sha512-tb5thFFlUcp7NdNF6/MpDk/1r/4awWG1FIz3YqDf+/zJSTezBb+/5WViH41obXULHVpDzoiCLpJ/ZO9YbJMsdw==} + /array.prototype.findlastindex@1.2.3: + resolution: {integrity: sha512-LzLoiOMAxvy+Gd3BAq3B7VeIgPdo+Q8hthvKtXybMvRV0jrXfJM/t8mw7nNlpEcVlVUnCnM2KSX4XU5HmpodOA==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.2 @@ -2593,7 +2593,7 @@ packages: dependencies: '@typescript-eslint/parser': 5.62.0(eslint@8.48.0)(typescript@5.2.2) array-includes: 3.1.6 - array.prototype.findlastindex: 1.2.2 + array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 debug: 3.2.7 @@ -2628,7 +2628,7 @@ packages: dependencies: '@typescript-eslint/parser': 6.5.0(eslint@8.48.0)(typescript@5.2.2) array-includes: 3.1.6 - array.prototype.findlastindex: 1.2.2 + array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 debug: 3.2.7 @@ -2651,8 +2651,8 @@ packages: - supports-color dev: true - /eslint-plugin-jsdoc@46.5.0(eslint@8.48.0): - resolution: {integrity: sha512-aulXdA4I1dyWpzyS1Nh/GNoS6PavzeucxEapnMR4JUERowWvaEk2Y4A5irpHAcdXtBBHLVe8WIhdXNjoAlGQgA==} + /eslint-plugin-jsdoc@46.5.1(eslint@8.48.0): + resolution: {integrity: sha512-CPbvKprmEuJYoxMj5g8gXfPqUGgcqMM6jpH06Kp4pn5Uy5MrPkFKzoD7UFp2E4RBzfXbJz1+TeuEivwFVMkXBg==} engines: {node: '>=16'} peerDependencies: eslint: ^7.0.0 || ^8.0.0 @@ -2814,7 +2814,7 @@ packages: '@eslint-community/regexpp': 4.8.0 '@eslint/eslintrc': 2.1.2 '@eslint/js': 8.48.0 - '@humanwhocodes/config-array': 0.11.10 + '@humanwhocodes/config-array': 0.11.11 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 ajv: 6.12.6 @@ -5954,8 +5954,8 @@ packages: resolution: {integrity: sha512-di2Hd1DB2Zfw6StGv861JoAF5h/uQVu/QJp2g8KVbtfKnoHdBQl5M32YWq6mnSYBQ1vFFrns5B1haWJL7rKaOQ==} dev: true - /terser@5.19.2: - resolution: {integrity: sha512-qC5+dmecKJA4cpYxRa5aVkKehYsQKc+AHeKl0Oe62aYjBL8ZA33tTljktDHJSaxxMnbI5ZYw+o/S2DxxLu8OfA==} + /terser@5.19.3: + resolution: {integrity: sha512-pQzJ9UJzM0IgmT4FAtYI6+VqFf0lj/to58AV0Xfgg0Up37RyPG7Al+1cepC6/BVuAxR9oNb41/DL4DEoHJvTdg==} engines: {node: '>=10'} hasBin: true dependencies: diff --git a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts index ca5b7db9..be762256 100644 --- a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts @@ -143,10 +143,13 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< public remove (workerNodeKey: number): boolean { if (this.nextWorkerNodeKey === workerNodeKey) { if (this.pool.workerNodes.length === 0) { + this.roundId = 0 + this.workerNodeId = 0 this.nextWorkerNodeKey = 0 } else if (this.nextWorkerNodeKey > this.pool.workerNodes.length - 1) { - this.roundId = - this.roundId === this.roundWeights.length - 1 ? 0 : this.roundId + 1 + if (this.workerNodeId === this.nextWorkerNodeKey) { + this.workerNodeId = this.pool.workerNodes.length - 1 + } this.nextWorkerNodeKey = this.pool.workerNodes.length - 1 } this.workerVirtualTaskRunTime = 0