Skip to content

Commit

Permalink
Merge pull request #341 from tom-binary/bugfix/stream_creation_race
Browse files Browse the repository at this point in the history
Handle stream creation race condition
  • Loading branch information
tom-binary authored Sep 5, 2024
2 parents 8472009 + b1e9525 commit a957ac0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Myriad/Transport/Redis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,15 @@ Then destroy that init consumer group.

async method create_stream ($stream) {
await $self->create_group($stream, 'INIT', '$', 1);
await $self->remove_group($stream, 'INIT');
try {
await $self->remove_group($stream, 'INIT');
} catch ($e) {
# If we have multiple instances, there's a race condition between creating the group
# and another instance trying to delete it before we get there. Ignore errors when
# that happens - we don't care who deleted the group, just that it goes away - but
# rethrow any other errors.
die $e unless $e =~ /NOGROUP/;
}
$log->tracef('created a Redis stream: %s', $stream);
}

Expand Down

0 comments on commit a957ac0

Please sign in to comment.