-
-
Notifications
You must be signed in to change notification settings - Fork 116
fix: potential data corruption bug and improve message sending behaviour #174
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
fix: potential data corruption bug and improve message sending behaviour #174
Conversation
2f20960 to
3c12160
Compare
…pply-loop-should-be-called-on
…pply-loop-should-be-called-on
iambriccardo
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.
Left some comments
| end_loop |= !hook | ||
| .process_syncing_tables(state.next_status_update.flush_lsn, true) | ||
| .await?; |
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.
With the process syncing here, the system becomes much harder to reason about, but I am failing to see any alternative that would work well with batching.
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.
Yes, it has become harder to see the logic, but as you said I can't think of a real alternative either.
| if let Some(table_id) = skip_table { | ||
| end_loop |= !hook.skip_table(table_id).await?; |
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.
Shouldn't this be outside of the sending of the batch? As far as I know we need to skip the table as soon as we get the event.
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 be called as soon as the relation event indicates a change in schema because the end_batch.is_some() part in the if time_to_send_batch || state.events_batch.len() >= max_batch_size || end_batch.is_some() condition will be true in that case (end_batch will be set to EndBatch::Exclusive).
This again is important to call only after the batch is acked because if we set the table state to skipped before that we run the risk of missing events.
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.
Oh yeah, nvm, I missed the last condition.
This PR:
ReplicationMessage<LogicalReplicationMessage>messages into a vec, which were later copied to another vec. This reduces number of allocations. Allocations can be further reduced if we send a slice to the destination instead of a vec, but that's not yet handled.I also wanted to create a stream which encapsulates the whole message filtering logic and produced
LogicalReplicationMessages and then batch the output of this stream, but this became complicated due to stream calling async methods. This will be done in a separate PR later on.