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

[connector] Fluss support scan.startup.timestamp is larger than max timestamp of bucket. #284

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

loserwang1024
Copy link
Collaborator

Purpose

Linked issue: close #274

@@ -166,7 +166,7 @@ void testPkTableReadOnlySnapshot() throws Exception {

@Test
void testNonPkTableRead() throws Exception {
tEnv.executeSql("create table non_pk_table_test (a int, b varchar)");
tEnv.executeSql("create table f (a int, b varchar)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misupdate?

@@ -631,6 +631,49 @@ void testReadPrimaryKeyPartitionedTable() throws Exception {
assertResultsIgnoreOrder(rowIter, expectedRowValues, true);
}

@Test
void testReadTimestampOutOfBounds() throws Exception {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove heading empty line

ApiException exception =
ApiError.fromErrorMessage(resp).exception();
if (exception
instanceof InvalidTimestampException) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not encouraged to use exceptions as common information exchanging. I would recommend this can be handled in server-side to simplify client-side implementation (and future other clients).

// requirement of the timestamp have not been produced to fluss yet. In this case, we just
// use the latest offset. We need to get the latest offsets before querying offsets by time
// to ensure that no message is going to be missed.
Map<Integer, Long> endOffsets = latestOffsets(partitionName, buckets);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend this fallback logic should be handled in server-side to have a data consistency and simplify client.

From the perspective of ListOffset(timestamp) RPC method semantics, it should "return the offset of the first message whose timestamp is greater than or equals to the given timestamp. If no such message is found, the log end offset is returned." We can still throw InvalidTimestampException if the timestamp is larger than current timestamp (a future time).

And then, adds unit tests in ReplicaManagerTest#testListOffsetsWithTimestamp.

This is also how kafka implement it: https://github.com/apache/kafka/blob/b40a962a8ead04b10f7a8eba346fe79784de9e4e/core/src/main/scala/kafka/log/UnifiedLog.scala#L1252-L1256

List<ListOffsetsResultForBucket> listOffsetsResultForBuckets = future1.get();
for (ListOffsetsResultForBucket result : listOffsetsResultForBuckets) {
if (result.getErrorCode() != 0) {
log.warn(result.getErrorMessage() + "," + result.getErrorCode());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only used for debugging? can be removed now?

RestartStrategyOptions.RESTART_STRATEGY,
RestartStrategyOptions.RestartStrategyType
.NO_RESTART_STRATEGY
.getMainValue()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to configure this?

@wuchong
Copy link
Member

wuchong commented Jan 18, 2025

@loserwang1024 I appended a commit to remove the unnecessary code. I will merge it if you have no concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Flink Source throw the fetch timestamp %s is larger than the max timestamp %s.
2 participants