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:
parent
7843c93dc5
commit
76a834ca91
@ -174,7 +174,7 @@ export default class FeatureToggleStore implements IFeatureToggleStore {
|
|||||||
const environmentArrays = this.mapMetricDataToEnvBuckets(data);
|
const environmentArrays = this.mapMetricDataToEnvBuckets(data);
|
||||||
try {
|
try {
|
||||||
for (const env of Object.keys(environmentArrays)) {
|
for (const env of Object.keys(environmentArrays)) {
|
||||||
const toggleNames = environmentArrays[env];
|
const toggleNames = environmentArrays[env].sort();
|
||||||
await this.db(FEATURE_ENVIRONMENTS_TABLE)
|
await this.db(FEATURE_ENVIRONMENTS_TABLE)
|
||||||
.update({ last_seen_at: now })
|
.update({ last_seen_at: now })
|
||||||
.where('environment', env)
|
.where('environment', env)
|
||||||
|
Loading…
Reference in New Issue
Block a user