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

*: deny unknown fields when deserializing config TOML #5190

Merged
merged 3 commits into from Aug 9, 2019

Conversation

kennytm
Copy link
Contributor

@kennytm kennytm commented Aug 4, 2019

What have you changed? (mandatory)

Add #[serde(deny_unknown_fields)] to all config structures, which will cause deserialization to fail if the source contains an unrecognized field. The rationale to catch typo or misplaced settings.

What are the type of the changes? (mandatory)

  • Improvement (change which is an improvement to an existing feature)

How has this PR been tested? (mandatory)

cargo test --test integrations -- test_error_on_unrecognized_config

Does this PR affect documentation (docs) or release note? (mandatory)

Release note.

Does this PR affect tidb-ansible update? (mandatory)

Hopefully no 🙃.

Refer to a related PR or issue link (optional)

pingcap/tidb#9855

Benchmark result if necessary (optional)

Add a few positive/negative examples (optional)

Signed-off-by: kennytm <kennytm@gmail.com>
@kennytm kennytm added component/server Component: Server type/changelog Type: PR - Need to be noted in the CHANGELOG labels Aug 4, 2019
@kennytm
Copy link
Contributor Author

kennytm commented Aug 4, 2019

/run-integration-tests

Copy link
Contributor

@siddontang siddontang left a comment

Choose a reason for hiding this comment

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

Great!

LGTM

Copy link
Member

@5kbpers 5kbpers left a comment

Choose a reason for hiding this comment

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

LGTM

@breezewish
Copy link
Member

Does this PR need to be cherry picked to 3.0?

@kennytm
Copy link
Contributor Author

kennytm commented Aug 5, 2019

@breeswish We could. WDYT

@breezewish
Copy link
Member

@BusyJay @overvenus Do you have some ideas?

@@ -75,6 +75,7 @@ fn memory_mb_for_cf(is_raft_db: bool, cf: &str) -> usize {

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(default)]
#[serde(deny_unknown_fields)]
Copy link
Member

Choose a reason for hiding this comment

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

Seems we can no longer downgrade if there is a new config exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You'd need to comment out that config manually. The error message will tell you the name of the offending field.

Copy link
Contributor

Choose a reason for hiding this comment

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

seem TiDB has the same problem now. is it ok?
@shenli

Copy link
Member

Choose a reason for hiding this comment

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

yes, I think so.

@kennytm kennytm added the status/can-merge Status: Can merge to base branch label Aug 9, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Aug 9, 2019

/run-all-tests

@sre-bot sre-bot merged commit 0343796 into tikv:master Aug 9, 2019
@breezewish
Copy link
Member

Need cherry pick? @siddontang @BusyJay

@kennytm kennytm deleted the deny-unknown-fields branch August 21, 2019 19:45
YangKeao pushed a commit to YangKeao/tikv that referenced this pull request Aug 26, 2019
kennytm added a commit to kennytm/tikv that referenced this pull request Aug 28, 2019
kennytm added a commit to kennytm/tikv that referenced this pull request Aug 28, 2019
)"

This reverts commit 0343796.

Signed-off-by: kennytm <kennytm@gmail.com>
kennytm added a commit to kennytm/tikv that referenced this pull request Aug 28, 2019
)"

This reverts commit 0343796.

Signed-off-by: kennytm <kennytm@gmail.com>
sre-bot pushed a commit that referenced this pull request Aug 28, 2019
YangKeao added a commit to YangKeao/tikv that referenced this pull request Sep 5, 2019
YangKeao added a commit to YangKeao/tikv that referenced this pull request Sep 5, 2019
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/server Component: Server status/can-merge Status: Can merge to base branch type/changelog Type: PR - Need to be noted in the CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants