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:
parent
e0409469ef
commit
790a7baf11
@ -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