1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01: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>
This commit is contained in:
andreas-unleash 2023-09-15 13:02:38 +03:00 committed by GitHub
parent 7843c93dc5
commit 76a834ca91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)