From 17cc8deb29b677f9b2a7eb7d7ada517b3c68ff2e Mon Sep 17 00:00:00 2001 From: guyhardonag Date: Thu, 11 Apr 2024 14:00:15 +0300 Subject: [PATCH] Wrap with kv slowdown err --- pkg/kv/dynamodb/store.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/kv/dynamodb/store.go b/pkg/kv/dynamodb/store.go index 71fc4bb374c..409fb080d50 100644 --- a/pkg/kv/dynamodb/store.go +++ b/pkg/kv/dynamodb/store.go @@ -241,6 +241,7 @@ func (s *Store) Get(ctx context.Context, partitionKey, key []byte) (*kv.ValueWit if s.isSlowDownErr(err) { s.logger.WithField("partition_key", partitionKey).WithContext(ctx).Error("get item: %w", kv.ErrSlowDown) dynamoSlowdown.WithLabelValues(operation).Inc() + err = errors.Join(err, kv.ErrSlowDown) } return nil, fmt.Errorf("get item: %w", err) } @@ -329,6 +330,7 @@ func (s *Store) setWithOptionalPredicate(ctx context.Context, partitionKey, key, if s.isSlowDownErr(err) { s.logger.WithField("partition_key", partitionKey).WithContext(ctx).Error("put item: %w", kv.ErrSlowDown) dynamoSlowdown.WithLabelValues(operation).Inc() + err = errors.Join(err, kv.ErrSlowDown) } return fmt.Errorf("put item: %w", err) } @@ -356,6 +358,7 @@ func (s *Store) Delete(ctx context.Context, partitionKey, key []byte) error { if s.isSlowDownErr(err) { s.logger.WithField("partition_key", partitionKey).WithContext(ctx).Error("delete item: %w", kv.ErrSlowDown) dynamoSlowdown.WithLabelValues(operation).Inc() + err = errors.Join(err, kv.ErrSlowDown) } return fmt.Errorf("delete item: %w", err) } @@ -384,11 +387,13 @@ func (s *Store) Scan(ctx context.Context, partitionKey []byte, options kv.ScanOp } it.runQuery() if it.err != nil { + err := it.err if s.isSlowDownErr(it.err) { s.logger.WithField("partition_key", partitionKey).WithContext(ctx).Error("scan: %w", kv.ErrSlowDown) dynamoSlowdown.WithLabelValues("Scan").Inc() + err = errors.Join(err, kv.ErrSlowDown) } - return nil, it.err + return nil, err } return it, nil } @@ -406,6 +411,7 @@ func (s *Store) DropTable() error { if s.isSlowDownErr(err) { s.logger.WithField("table", s.params.TableName).WithContext(ctx).Error("drop table: %w", kv.ErrSlowDown) dynamoSlowdown.WithLabelValues("DeleteTable").Inc() + err = errors.Join(err, kv.ErrSlowDown) } return err }