You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TimeCast: don't block mediator time for tablets without transactions #6512
We currently have a problem where one tablet in a timecast bucket may block mediator time for all other tablets in the same bucket. We need a way to solve this problem with backwards compatible protocol. Here's how we could solve this:
Add a new granular watch protocol (TEvMediatorTimecast::TEvGranularWatch) with a list of tablets that timecast service is watching. Unlike previous watch protocol it will always return the latest step, while also tracking frozen steps for tablets we subscribed to.
Add a TEvGranularWatchModify message which would allow adding and removing tablets with an updated seqno
When mediator supports the new protocol it will send TEvGranularWatchUpdate messages with the latest known step, freezes for tablets that have pending unacknowledged transactions and unfreezes for tablets that join the common time stream.
Timecast service will use the two atomic variables approach with freeze/unfreeze to advance tablet time. It will also subscribe to both the old and new watch protocol, using the old protocol to advance time for all tablets simultaneously, and granular protocol for more specific updates when available. Special care will be needed when connection to mediator switches between versions of the old and new protocol, the conflicting information will need to be synchronized somehow.
I'm working on changes in the timecast service, and there are some additional details:
I decided to use three atomics, shared SafeStep (old watches protocol), shared LatestStep (new granular watches protocol) and per tablet FrozenStep. This will allow the old and the new protocols to work without interference. Using SafeStep as the minimum mediator time will ensure all tablets keep updating when reconnecting to mediators that don't support granular protocol, and we don't have to somehow translate frozen steps from the old to the new protocol.
The trickiest part is to ensure mediator time never jumps backwards when reconnecting. For the old protocol it is a simple case of never allowing SafeStep to decrease, but for the new protocol it's much trickier, since we may reconnect to a mediator that lives "in the past" while the transaction stream is replayed. We cannot decrease LatestStep either, but we must make sure tablets frozen time doesn't jump into the past.
I think the easiest would be to remember the last LatestStep we observed and delay processing granular updates until their time synchronizes with the last observed. We must aggregate freezes/unfreezes until that time however. In hindsight it's probably easier to do that at the mediator, tracking per-watcher minimum step and delaying the first update until AcceptedStep reaches that time.
I have observed that this change improves latency on a very specific benchmark where shards with distributed transactions and readonly shards overlap. Without granular timecast starting distributed upserts to unrelated tables causes a significant drop in read-only workload, with granular timecast read-only workload is unaffected. I'm not sure whether it helps in less synthetic cases though, I couldn't see any improvement in some quick benchmarks that I had.
Activity
snaury commentedon Aug 20, 2024
I'm working on changes in the timecast service, and there are some additional details:
I decided to use three atomics, shared
SafeStep(old watches protocol), sharedLatestStep(new granular watches protocol) and per tabletFrozenStep. This will allow the old and the new protocols to work without interference. UsingSafeStepas the minimum mediator time will ensure all tablets keep updating when reconnecting to mediators that don't support granular protocol, and we don't have to somehow translate frozen steps from the old to the new protocol.The trickiest part is to ensure mediator time never jumps backwards when reconnecting. For the old protocol it is a simple case of never allowing SafeStep to decrease, but for the new protocol it's much trickier, since we may reconnect to a mediator that lives "in the past" while the transaction stream is replayed. We cannot decrease LatestStep either, but we must make sure tablets frozen time doesn't jump into the past.
I think the easiest would be to remember the last
LatestStepwe observed and delay processing granular updates until their time synchronizes with the last observed. We must aggregate freezes/unfreezes until that time however. In hindsight it's probably easier to do that at the mediator, tracking per-watcher minimum step and delaying the first update until AcceptedStep reaches that time.snaury commentedon Aug 22, 2024
I have observed that this change improves latency on a very specific benchmark where shards with distributed transactions and readonly shards overlap. Without granular timecast starting distributed upserts to unrelated tables causes a significant drop in read-only workload, with granular timecast read-only workload is unaffected. I'm not sure whether it helps in less synthetic cases though, I couldn't see any improvement in some quick benchmarks that I had.