-
Notifications
You must be signed in to change notification settings - Fork 587
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
feat(sink): set default_sink_decouple = true for all sink #18182
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
785e166
su
xxhZs 30d4a2c
fix ci
xxhZs c1e1e16
Merge branch 'main' into xxh/sink-decouple-
xxhZs 37f942d
Merge branch 'main' into xxh/sink-decouple-
xxhZs 5b67a76
Merge branch 'main' into xxh/sink-decouple-
xxhZs 2a6fca4
Merge branch 'main' into xxh/sink-decouple-
xxhZs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
statement ok | ||
set sink_decouple = false; | ||
|
||
statement ok | ||
CREATE TABLE t7 ( | ||
v1 int primary key, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,16 +30,18 @@ use risingwave_common::types::{DataType, Decimal, ScalarRefImpl, Serial}; | |
use serde::ser::{SerializeSeq, SerializeStruct}; | ||
use serde::Serialize; | ||
use serde_derive::Deserialize; | ||
use serde_with::serde_as; | ||
use serde_with::{serde_as, DisplayFromStr}; | ||
use thiserror_ext::AsReport; | ||
use tonic::async_trait; | ||
use tracing::warn; | ||
use with_options::WithOptions; | ||
|
||
use super::decouple_checkpoint_log_sink::DecoupleCheckpointLogSinkerOf; | ||
use super::decouple_checkpoint_log_sink::{ | ||
default_commit_checkpoint_interval, DecoupleCheckpointLogSinkerOf, | ||
DEFAULT_COMMIT_CHECKPOINT_INTERVAL, | ||
}; | ||
use super::writer::SinkWriter; | ||
use super::{DummySinkCommitCoordinator, SinkWriterParam}; | ||
use crate::deserialize_optional_u64_from_string; | ||
use crate::error::ConnectorResult; | ||
use crate::sink::catalog::desc::SinkDesc; | ||
use crate::sink::{ | ||
|
@@ -52,6 +54,7 @@ const QUERY_COLUMN: &str = | |
"select distinct ?fields from system.columns where database = ? and table = ? order by ?"; | ||
pub const CLICKHOUSE_SINK: &str = "clickhouse"; | ||
|
||
#[serde_as] | ||
#[derive(Deserialize, Debug, Clone, WithOptions)] | ||
pub struct ClickHouseCommon { | ||
#[serde(rename = "clickhouse.url")] | ||
|
@@ -66,9 +69,10 @@ pub struct ClickHouseCommon { | |
pub table: String, | ||
#[serde(rename = "clickhouse.delete.column")] | ||
pub delete_column: Option<String>, | ||
/// Commit every n(>0) checkpoints, if n is not set, we will commit every checkpoint. | ||
#[serde(default, deserialize_with = "deserialize_optional_u64_from_string")] | ||
pub commit_checkpoint_interval: Option<u64>, | ||
/// Commit every n(>0) checkpoints, default is 10. | ||
#[serde(default = "default_commit_checkpoint_interval")] | ||
#[serde_as(as = "DisplayFromStr")] | ||
pub commit_checkpoint_interval: u64, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding of the change to default value, don't forget to update the doc as well. :) |
||
} | ||
|
||
#[allow(clippy::enum_variant_names)] | ||
|
@@ -494,26 +498,25 @@ impl Sink for ClickHouseSink { | |
const SINK_NAME: &'static str = CLICKHOUSE_SINK; | ||
|
||
fn is_sink_decouple(desc: &SinkDesc, user_specified: &SinkDecouple) -> Result<bool> { | ||
let config_decouple = if let Some(interval) = | ||
desc.properties.get("commit_checkpoint_interval") | ||
&& interval.parse::<u64>().unwrap_or(0) > 1 | ||
{ | ||
true | ||
} else { | ||
false | ||
}; | ||
let commit_checkpoint_interval = | ||
if let Some(interval) = desc.properties.get("commit_checkpoint_interval") { | ||
interval | ||
.parse::<u64>() | ||
.unwrap_or(DEFAULT_COMMIT_CHECKPOINT_INTERVAL) | ||
} else { | ||
DEFAULT_COMMIT_CHECKPOINT_INTERVAL | ||
}; | ||
|
||
match user_specified { | ||
SinkDecouple::Default => Ok(config_decouple), | ||
SinkDecouple::Default | SinkDecouple::Enable => Ok(true), | ||
SinkDecouple::Disable => { | ||
if config_decouple { | ||
if commit_checkpoint_interval > 1 { | ||
return Err(SinkError::Config(anyhow!( | ||
"config conflict: Clickhouse config `commit_checkpoint_interval` larger than 1 means that sink decouple must be enabled, but session config sink_decouple is disabled" | ||
))); | ||
} | ||
Ok(false) | ||
} | ||
SinkDecouple::Enable => Ok(true), | ||
} | ||
} | ||
|
||
|
@@ -552,9 +555,9 @@ impl Sink for ClickHouseSink { | |
self.check_pk_match(&clickhouse_column)?; | ||
} | ||
|
||
if self.config.common.commit_checkpoint_interval == Some(0) { | ||
if self.config.common.commit_checkpoint_interval == 0 { | ||
return Err(SinkError::Config(anyhow!( | ||
"commit_checkpoint_interval must be greater than 0" | ||
"`commit_checkpoint_interval` must be greater than 0" | ||
))); | ||
} | ||
Ok(()) | ||
|
@@ -569,7 +572,7 @@ impl Sink for ClickHouseSink { | |
) | ||
.await?; | ||
let commit_checkpoint_interval = | ||
NonZeroU64::new(self.config.common.commit_checkpoint_interval.unwrap_or(1)).expect( | ||
NonZeroU64::new(self.config.common.commit_checkpoint_interval).expect( | ||
"commit_checkpoint_interval should be greater than 0, and it should be checked in config validation", | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 setting this field just to implicitly enable sink decouple, or it becomes required to set this field after this PR?
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.
Because sink_decouple = false will report an error when commit_checkpoint_interval >10;
And in ci , we need sink_decouple = false to ensure that flush can flush data to sink.
So we set commit_checkpoint_interval = 1,
After this PR, if it is not set, a default value of 10 will be given