Skip to content

[client] Add validation for client.scanner.log.max-poll-records and client.connect-timeout - #3069

Merged
fresh-borzoni merged 2 commits into
apache:mainfrom
pbanakar:client-Add-validation
Jun 26, 2026
Merged

[client] Add validation for client.scanner.log.max-poll-records and client.connect-timeout#3069
fresh-borzoni merged 2 commits into
apache:mainfrom
pbanakar:client-Add-validation

Conversation

@pbanakar

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #3068

Add client config validation for client.scanner.log.max-poll-records and client.connect-timeout during FlussConnection initialization. Setting either of these to 0 or negative makes no practical sense — poll() would return nothing and TCP connect would time out immediately.

Brief change log

  • Added validateClientConfigs() in FlussConfigUtils covering client.scanner.log.max-poll-records (must be > 0) and client.connect-timeout (must be > 0)
  • Called validateClientConfigs() in FlussConnection constructor
  • Added unit tests in FlussConfigUtilsTest

Tests

Existing FlussConfigUtilsTest extended with testValidateClientConfigs() covering default validity and each invalid case.

API and Format

NO

Documentation

NO

@pbanakar

Copy link
Copy Markdown
Contributor Author

cc @fresh-borzoni @LiebingYu

@fresh-borzoni fresh-borzoni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Prajwal-banakar Ty for the PR, left some comments, PTAL


public static void validateClientConfigs(Configuration conf) {
int maxPollRecords = conf.getInt(ConfigOptions.CLIENT_SCANNER_LOG_MAX_POLL_RECORDS);
if (maxPollRecords <= 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shall we use validMinValue?

@pbanakar pbanakar Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks! Switched to validMinValue

}

long connectTimeoutMs = conf.get(ConfigOptions.CLIENT_CONNECT_TIMEOUT).toMillis();
if (connectTimeoutMs <= 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

mb we can have validMinDuration(conf, option, minMillis) helper to match the existing pattern?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added a validMinDuration helper

Configuration.fromMap(
extractPrefix(new HashMap<>(conf.toMap()), CLIENT_PREFIX + "fs.")),
null);
FlussConfigUtils.validateClientConfigs(conf);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: can we move FlussConfigUtils.validateClientConfigs(conf) to the very first line of the constructor, before FileSystem.initialize(...) and setupClientMetricsConfiguration()?

Right now a bad config still initializes the filesystem and sets up metrics before failing, while fail-fast is cheaper and avoids partial side effects.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated to validate at the beginning of the constructor


// connect-timeout = 0 should fail
Configuration zeroTimeoutConf = new Configuration();
zeroTimeoutConf.set(ConfigOptions.CLIENT_CONNECT_TIMEOUT, java.time.Duration.ZERO);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: why fully qualified name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

replaced with import

@pbanakar
pbanakar requested a review from fresh-borzoni April 17, 2026 08:44
@pbanakar

Copy link
Copy Markdown
Contributor Author

Hi @fresh-borzoni adressed all the comments, could you please take another look when you get a chance? thanks!

@pbanakar

Copy link
Copy Markdown
Contributor Author

Hi @fresh-borzoni PTAL another look here when you have some time, Thanks!

@fresh-borzoni fresh-borzoni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Prajwal-banakar Sorry, I missed this, LGTM, thank you 👍

@fresh-borzoni
fresh-borzoni merged commit 486fe0a into apache:main Jun 26, 2026
6 checks passed
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.

[client] Add validation for client.scanner.log.max-poll-records and client.connect-timeout config options

2 participants