1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-18 13:48:58 +02:00

fix: sort toggleNames before updating last seen (#4747)

Seems like when 2 pods are trying to POST lastSeen metrics, the db gets
into a deadlock state.

This is an attempt to fix the deadlock by sorting the toggleNames before
the update.

The hypothesis is that sorted toggle names will reduce the chance of
working on the same row at the same exact time

Closes #
[1-1382](https://linear.app/unleash/issue/1-1382/order-data-before-updating-the-lastseen-to-reduce-change-of-deadlock)

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
(cherry picked from commit 76a834ca91)
This commit is contained in:
andreas-unleash 2023-09-15 13:02:38 +03:00
parent e0409469ef
commit 790a7baf11
No known key found for this signature in database
GPG Key ID: DB82A1577B38F66B

View File

@ -174,7 +174,7 @@ export default class FeatureToggleStore implements IFeatureToggleStore {
const environmentArrays = this.mapMetricDataToEnvBuckets(data);
try {
for (const env of Object.keys(environmentArrays)) {
const toggleNames = environmentArrays[env];
const toggleNames = environmentArrays[env].sort();
await this.db(FEATURE_ENVIRONMENTS_TABLE)
.update({ last_seen_at: now })
.where('environment', env)