Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle stream creation race condition #341

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading