Skip to content

Commit b618974

Browse files
jon-chuangTennyZhuanggithub-actions[bot]
authored
feat(executor): DynamicFilter write right table state exactly once - only if actor owns vnode = 0 (#3783)
* initial * stash * do-appply-planner-test * fmt * clippy * license * minor * stash * fix required dist, output indices * fmt * stash * revert * do-apply-planner-test * success! * more e2e * minor cleanup * stash * fix * fix * fix * minor * minor * madsim * clippy * fmt * minor * fix * fix, apply code review suggestions * fix * fix, improve * simplify * clippy * refactor into sub functions * clippy * minor * fix * fix: rowsort * fmt * use literal in expression * clippy * fmt * use madsim btreemap * minor * fmt * respect previous behaviour - return empty message * bump-ci * use correct enum * add state table * fmt * prepare for cache policy * fmt * minor * minor * minor * Update src/stream/src/executor/managed_state/dynamic_filter.rs add license Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fmt * add state table for RHS * minor * fmt * add right_table to executor * minor * fmt * fix * clippy * fmt * fix double write * use correct * try to write on every msg * fix weird omissions * bump * minor * revert q18, q20 * revert q4 * remove inserts * only insert for right table * try to insert at barrier only * add asserts * debug * fix * fmt * only write on vnode = 0 * minor * minor * use bool as we need to read from RHS in the future... (for recovery)... Co-authored-by: TennyZhuang <zty0826@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent fd0b7e2 commit b618974

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/stream/src/executor/dynamic_filter.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub struct DynamicFilterExecutor<S: StateStore> {
4747
comparator: ExprNodeType,
4848
range_cache: RangeCache<S>,
4949
right_table: StateTable<S>,
50+
is_right_table_writer: bool,
5051
actor_id: u64,
5152
schema: Schema,
5253
metrics: Arc<StreamingMetrics>,
@@ -63,6 +64,7 @@ impl<S: StateStore> DynamicFilterExecutor<S> {
6364
comparator: ExprNodeType,
6465
state_table_l: StateTable<S>,
6566
state_table_r: StateTable<S>,
67+
is_right_table_writer: bool,
6668
actor_id: u64,
6769
metrics: Arc<StreamingMetrics>,
6870
) -> Self {
@@ -76,6 +78,7 @@ impl<S: StateStore> DynamicFilterExecutor<S> {
7678
comparator,
7779
range_cache: RangeCache::new(state_table_l, 0, usize::MAX),
7880
right_table: state_table_r,
81+
is_right_table_writer,
7982
actor_id,
8083
metrics,
8184
schema,
@@ -240,6 +243,7 @@ impl<S: StateStore> DynamicFilterExecutor<S> {
240243

241244
let mut prev_epoch_value: Option<Datum> = None;
242245
let mut current_epoch_value: Option<Datum> = None;
246+
let mut current_epoch_row = None;
243247
let mut epoch: u64 = 0;
244248

245249
let aligned_stream = barrier_align(
@@ -288,11 +292,10 @@ impl<S: StateStore> DynamicFilterExecutor<S> {
288292
Op::UpdateInsert | Op::Insert => {
289293
last_is_insert = true;
290294
current_epoch_value = Some(row.value_at(0).to_owned_datum());
291-
// self.right_table.insert(row.to_owned_row())?;
295+
current_epoch_row = Some(row.to_owned_row());
292296
}
293-
Op::UpdateDelete | Op::Delete => {
297+
_ => {
294298
last_is_insert = false;
295-
// self.right_table.delete(row.to_owned_row())?;
296299
}
297300
}
298301
}
@@ -330,7 +333,14 @@ impl<S: StateStore> DynamicFilterExecutor<S> {
330333
yield Message::Chunk(chunk);
331334
}
332335
}
333-
self.right_table.commit(epoch).await?;
336+
337+
if self.is_right_table_writer {
338+
if let Some(row) = current_epoch_row.take() {
339+
assert_eq!(epoch, barrier.epoch.prev);
340+
self.right_table.insert(row)?;
341+
self.right_table.commit(epoch).await?;
342+
}
343+
}
334344

335345
self.range_cache.flush().await?;
336346

src/stream/src/from_proto/dynamic_filter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ impl ExecutorBuilder for DynamicFilterExecutorBuilder {
5252
));
5353
}
5454

55+
// Only write the RHS value if this actor is in charge of vnode 0
56+
let is_right_table_writer = vnodes.is_set(0)?;
57+
5558
let state_table_l =
5659
StateTable::from_table_catalog(node.get_left_table()?, store.clone(), Some(vnodes));
5760

@@ -66,6 +69,7 @@ impl ExecutorBuilder for DynamicFilterExecutorBuilder {
6669
comparator,
6770
state_table_l,
6871
state_table_r,
72+
is_right_table_writer,
6973
params.actor_id as u64,
7074
params.executor_stats,
7175
)))

0 commit comments

Comments
 (0)