-
Notifications
You must be signed in to change notification settings - Fork 18
Use long windows when catching up #67
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
base: master
Are you sure you want to change the base?
Conversation
public static TaskState createInitialFor(GenerationId generation, Timestamp now, | ||
long confidenceWindowSizeMs, long queryTimeWindowSizeMs) { | ||
// Start reading at generation start: | ||
Timestamp windowStart = generation.getGenerationStart(); |
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.
What was the conclusion of your tests @avelanarius? Does it make sense to take max(generation.getGenerationStart(), now - CDC ttl)?
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 made sense. The test was the following: create a table with small TTL (3 seconds), insert 10^6 rows, then do two types of selects: select of small window and select of a large window. Both of those queries returned no rows (3 second TTL...), but a select of small window was faster. Sometimes, select of a large window even caused timeouts (even though no rows were returned). We hypothesized that this is due to replicas sending "tombstones" to coordinator.
// queryTimeWindowSizeMs large (the consumer might need to wait a bit | ||
// for the window to be ready for reading). | ||
Timestamp windowEnd = now.plus(-confidenceWindowSizeMs, ChronoUnit.MILLIS); | ||
if (windowEnd.compareTo(windowStart) < 0) { |
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.
Is this enough? Wouldn't we want to adjust windowEnd also when windowEnd - windowStart < queryTimeWindowSizeMs
?
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.
Maybe, but this is only an initial window so it doesn't really matter.
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.
I could add this at the cost of additional complexity.
|
||
return this; | ||
// Trim the start of the window with minimumWindowStart. | ||
Timestamp newWindowStart = windowStart; |
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.
Why wasn't this needed before and now is? Or was it and it was a bug we weren't trimming the start?
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.
Previously it only handled one case:
---- WINDOW --- | TTL
->
---- WINDOW ---
Now it also handles this case:
---- WINDOW ---
| TTL
->
- WINDOW -
| TTL
Previously it didn't really matter to do the second type of trimming, because the windows were very small (default 30 seconds).
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.
LGTM in general
Changes the strategy the CDC library uses to generate windows to read the CDC log. Previously, when a library was started, it would read queryTimeWindowSize large windows starting from |now - ttl|. The issue with that approach is that it requires a large number of windows to catch up, for example: 24 hours / 30 seconds * 256 * 8 = 5898240 for a 8-shard Scylla server. A new approach just creates a single large window from |now - ttl| to |now - confidence window|.
1b7f0ba
to
ec66dab
Compare
v2: fixed flaky unit test. (off-by-one error) |
Any news here? I'm pretty interested in this PR |
012c0c8
to
c89661c
Compare
396912a
to
78c0d0b
Compare
3c4bf55
to
3318b32
Compare
5031da9
to
b5730b8
Compare
Changes the strategy the CDC library uses to generate windows to read the CDC log. Previously, when a library was started, it would read queryTimeWindowSize large windows starting from |now - ttl|. The issue with that approach is that it requires a large number of windows to catch up, for example: 24 hours / 30 seconds * 256 * 8 = 5898240 for a 8-shard Scylla server.
A new approach just creates a single large window from |now - ttl| to |now - confidence window|.