Skip to content

Commit

Permalink
DynamoDB Respect lineage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Jun 27, 2024
1 parent e6a1e73 commit 9125d4b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sources/dynamodb/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ func (s *StreamStore) processShard(ctx context.Context, shard *dynamodbstreams.S
return
}

if shard.ParentShardId != nil {
parentID := *shard.ParentShardId
if s.storage.GetShardProcessing(parentID) && !s.storage.GetShardProcessed(parentID) {
slog.Info("Parent shard is being processed, let's sleep 3s and retry", slog.String("shardId", *shard.ShardId))
if parentID := shard.ParentShardId; parentID != nil {
// If the parent shard exists, is it still being processed? If so, let's wait a bit and then retry.
// We must process the parent shard first before processing the child shard.
if s.storage.GetShardProcessing(*parentID) && !s.storage.GetShardProcessed(*parentID) {
slog.Info("Parent shard is being processed, let's sleep 3s and retry", slog.String("shardId", *shard.ShardId), slog.String("parentShardId", *parentID))
time.Sleep(3 * time.Second)
s.processShard(ctx, shard, writer)
return
Expand Down

0 comments on commit 9125d4b

Please sign in to comment.