Skip to content

Commit

Permalink
Wrap with kv slowdown err
Browse files Browse the repository at this point in the history
  • Loading branch information
guy-har committed Apr 15, 2024
1 parent 1e6647b commit 17cc8de
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/kv/dynamodb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 17cc8de

Please sign in to comment.