Skip to content

Commit

Permalink
Handle stream creation race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-binary committed Sep 5, 2024
1 parent 8472009 commit b1e9525
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 b1e9525

Please sign in to comment.