From 3fe8f0dd4a4e82ffea77fb9886d49f16a6b73acd Mon Sep 17 00:00:00 2001 From: almostinf Date: Tue, 21 Nov 2023 10:21:54 +0300 Subject: [PATCH 1/2] reduce transaction_timeout and returned random seed --- cmd/notifier/config.go | 2 +- database/redis/database.go | 4 ++-- database/redis/metric.go | 2 +- local/notifier.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/notifier/config.go b/cmd/notifier/config.go index 5cfddf9b0..1043dd2d4 100644 --- a/cmd/notifier/config.go +++ b/cmd/notifier/config.go @@ -96,7 +96,7 @@ func getDefault() config { }, Notification: cmd.NotificationConfig{ DelayedTime: "1m", - TransactionTimeout: "200ms", + TransactionTimeout: "100ms", TransactionMaxRetries: 10, TransactionHeuristicLimit: 10000, }, diff --git a/database/redis/database.go b/database/redis/database.go index 07b0c72c6..9b23f2cec 100644 --- a/database/redis/database.go +++ b/database/redis/database.go @@ -97,7 +97,7 @@ func NewTestDatabase(logger moira.Logger) *DbConnector { }, NotificationConfig{ DelayedTime: time.Minute, - TransactionTimeout: 200 * time.Millisecond, + TransactionTimeout: 100 * time.Millisecond, TransactionMaxRetries: 10, TransactionHeuristicLimit: 10000, }, @@ -114,7 +114,7 @@ func NewTestDatabaseWithIncorrectConfig(logger moira.Logger) *DbConnector { }, NotificationConfig{ DelayedTime: time.Minute, - TransactionTimeout: 200 * time.Millisecond, + TransactionTimeout: 100 * time.Millisecond, TransactionMaxRetries: 10, TransactionHeuristicLimit: 10000, }, diff --git a/database/redis/metric.go b/database/redis/metric.go index f27a96a88..a0e349d8a 100644 --- a/database/redis/metric.go +++ b/database/redis/metric.go @@ -105,7 +105,7 @@ func (connector *DbConnector) SaveMetrics(metrics map[string]*moira.MatchedMetri c := *connector.client ctx := connector.context - rand.New(rand.NewSource(time.Now().Unix())) + rand.Seed(time.Now().UnixNano()) pipe := c.TxPipeline() for _, metric := range metrics { diff --git a/local/notifier.yml b/local/notifier.yml index ff0e2b8de..925dbb5c4 100644 --- a/local/notifier.yml +++ b/local/notifier.yml @@ -44,7 +44,7 @@ notification_history: query_limit: 10000 notification: delayed_time: 1m - transaction_timeout: 200ms + transaction_timeout: 100ms transaction_max_retries: 10 transaction_heuristic_limit: 10000 log: From fd963a4ccb041e4435928c2769ab0ba37cbb0752 Mon Sep 17 00:00:00 2001 From: almostinf Date: Tue, 21 Nov 2023 11:13:34 +0300 Subject: [PATCH 2/2] fix lint --- database/redis/metric.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/redis/metric.go b/database/redis/metric.go index a0e349d8a..663008541 100644 --- a/database/redis/metric.go +++ b/database/redis/metric.go @@ -105,7 +105,7 @@ func (connector *DbConnector) SaveMetrics(metrics map[string]*moira.MatchedMetri c := *connector.client ctx := connector.context - rand.Seed(time.Now().UnixNano()) + rand := rand.New(rand.NewSource(time.Now().UnixNano())) pipe := c.TxPipeline() for _, metric := range metrics {