-
Notifications
You must be signed in to change notification settings - Fork 23
[OCTRL-998]: Sending kafka messages in wrong order #680
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
Conversation
This goroutine can cause race condition that makes kafka messages in wrong order
knopers8
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed I am afraid this will have a performance hit and might block the core in case of any event writer hiccup. Could we use a buffered channel of a reasonable length (100-1000?) and do non-blocking sends in WriteEvent and WriteEventWithTimestamp, while there would be a goroutine on the other side to consume and perform writing?
|
Good idea, will do |
|
I did it... but I guess that it is the same functionality as just Saying Async = true for the kafka-go library... except we can print errors if we encounter some during writing... it would be possible to create some error checker (eg. store encountered errors in kafkaWriter and check if he encountered some periodically), but I don't know if it is realy necessary and if error message in IL is enough, especially when there will be a lot of them if we cannot write into kafka |
yes indeed, this is why i still opted for this solution. I assume with Async = true we would be blind. |
common/event/writer.go
Outdated
| if err != nil { | ||
| return fmt.Errorf("failed to write event: %w", err) | ||
| } | ||
| w.toWriteChan <- message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will block if the buffer is full. Should we make it non-blocking perhaps?
There was a goroutine in
WriteEventWithTimestampwhich can cause race condition resulting in problems mentioned in ticket OCTRL-998.However, there can be performance problems caused by removing this concurrence, as every Kafka write call will wait until the message is send by the writer. This can be prevented by setting writer into async mode. But doing so we won't get any errors that might happen while sending messages. From kafka-go/writer.go Async comment: