Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/risingwavelabs/risingwave i…
Browse files Browse the repository at this point in the history
…nto li0k/storage_fix_strategy_for_append_only
Li0k committed Jan 24, 2025
2 parents ef2ea4f + 96e8158 commit 50b7709
Showing 2 changed files with 42 additions and 4 deletions.
30 changes: 30 additions & 0 deletions e2e_test/source_inline/kafka/shared_source.slt.serial
Original file line number Diff line number Diff line change
@@ -99,6 +99,10 @@ SET streaming_use_shared_source TO false;
statement ok
create materialized view mv_2 as select * from s0;

statement ok
SET streaming_use_shared_source TO true;


sleep 2s

query ?? rowsort
@@ -370,3 +374,29 @@ drop source s0 cascade;

statement ok
drop source s_before_produce cascade;

# test: scan.startup.mode=latest should not be blocked when there's no data to backfill
# https://github.com/risingwavelabs/risingwave/issues/20083#issuecomment-2609422824
statement ok
create source s_latest (v1 int, v2 varchar) with (
${RISEDEV_KAFKA_WITH_OPTIONS_COMMON},
topic = 'shared_source',
scan.startup.mode = 'latest'
) FORMAT PLAIN ENCODE JSON;

# Note: batch kafka scan ignores scan.startup.mode
query ? rowsort
select count(*) from s_latest;
----
55

statement ok
create materialized view mv_latest as select * from s_latest;

query ? rowsort
select count(*) from mv_latest;
----
0

system ok
rpk topic delete shared_source;
16 changes: 12 additions & 4 deletions src/connector/src/source/kafka/source/reader.rs
Original file line number Diff line number Diff line change
@@ -124,9 +124,9 @@ impl SplitReader for KafkaSplitReader {
properties.common.sync_call_timeout,
)
.await?;
tracing::debug!("fetch kafka watermarks: low: {low}, high: {high}, split: {split:?}");
// note: low is inclusive, high is exclusive
if low == high {
tracing::info!("fetch kafka watermarks: low: {low}, high: {high}, split: {split:?}");
// note: low is inclusive, high is exclusive, start_offset is exclusive
if low == high || split.start_offset.is_some_and(|offset| offset + 1 >= high) {
backfill_info.insert(split.id(), BackfillInfo::NoDataToBackfill);
} else {
debug_assert!(high > 0);
@@ -138,7 +138,15 @@ impl SplitReader for KafkaSplitReader {
);
}
}
tracing::debug!("backfill_info: {:?}", backfill_info);
tracing::info!(
topic = properties.common.topic,
source_name = source_ctx.source_name,
fragment_id = source_ctx.fragment_id,
source_id = source_ctx.source_id.table_id,
actor_id = source_ctx.actor_id,
"backfill_info: {:?}",
backfill_info
);

consumer.assign(&tpl)?;

0 comments on commit 50b7709

Please sign in to comment.