-
Notifications
You must be signed in to change notification settings - Fork 82
Set telemetry retention policy asynchronously #10416
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
Open
bnaecker
wants to merge
2
commits into
main
Choose a base branch
from
ben/set-retention-policy-take2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
8 changes: 8 additions & 0 deletions
8
clickhouse-admin/types/versions/src/add_retention_policy_for_all_tables/mod.rs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| //! Version `ADD_RETENTION_POLICY_FOR_ALL_TABLES` of the clickhouse-admin | ||
| //! server API. | ||
| pub mod retention; |
55 changes: 55 additions & 0 deletions
55
clickhouse-admin/types/versions/src/add_retention_policy_for_all_tables/retention.rs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| use crate::v2::retention::Days; | ||
| use iddqd::IdOrdItem; | ||
| use iddqd::IdOrdMap; | ||
| use iddqd::id_upcast; | ||
| use schemars::JsonSchema; | ||
| use serde::Deserialize; | ||
| use serde::Serialize; | ||
|
|
||
| /// A request for setting a retention policy. | ||
| #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] | ||
| pub struct RetentionPolicyRequest { | ||
| /// The requested retention period, in days. | ||
| pub days: Days, | ||
| } | ||
|
|
||
| impl From<crate::v2::retention::RetentionPolicy> for RetentionPolicyRequest { | ||
| fn from(value: crate::v2::retention::RetentionPolicy) -> Self { | ||
| Self { days: value.days } | ||
| } | ||
| } | ||
|
|
||
| /// Policy for retaining telemetry data for a database table. | ||
| #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] | ||
| pub struct RetentionPolicy { | ||
| /// The table the policy applies to. | ||
| pub table: String, | ||
| /// The retention period, in days. | ||
| pub days: Days, | ||
| } | ||
|
|
||
| impl From<RetentionPolicy> for crate::v2::retention::RetentionPolicy { | ||
| fn from(value: RetentionPolicy) -> Self { | ||
| Self { days: value.days } | ||
| } | ||
| } | ||
|
|
||
| impl IdOrdItem for RetentionPolicy { | ||
| type Key<'a> = &'a str; | ||
|
|
||
| fn key(&self) -> Self::Key<'_> { | ||
| self.table.as_str() | ||
| } | ||
|
|
||
| id_upcast!(); | ||
| } | ||
|
|
||
| /// Policy for retaining telemetry data for all tables. | ||
| #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] | ||
| pub struct DatabaseRetentionPolicy { | ||
| pub tables: IdOrdMap<RetentionPolicy>, | ||
| } |
This file contains hidden or 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 hidden or 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.
Nit: I think it would be worth a note that this update is eventually consistent. IIUC, a user could set the retention policy, immediately read it back, and be surprised that it's not (yet) the expected value.
And a question: with
SETTINGS mutations_sync=0, is it possible to queue an update that never succeeds? Speaking of which, have we tested what happens here when the disk is full, which is the issue that triggered this feature in the first place? I don't want to delay merging on this question, but we might want to figure it out sometime if we haven't already.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.
Good idea about the note.
Yes, I think it's possible for a background mutation to fail. The description for the
system.mutationstable lists columns likelast_fail_time, for example. I can't find on that page or any other whether mutations are retried. The phrasing "last fail time" makes me think they are, but that's not clear.I'm not sure what happens if the disk is full, we haven't attempted it and it is hard to reproduce. From this page it appears that whole data parts (chunks of tables) are rewritten according to the mutation, and then the original is dropped. Depending on how the TTL is implemented, that could certainly lead to write amplification. It's a valid concern, and we should flag it for testing. I'm...fairly confident... that it will not cause more pain than we've already had because we're expecting to reduce the retention time which would lead to all or most of a data part being dropped, not rewritten with say, a different order. Or maybe I'm just hopeful.
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.
Actually there's this:
From this page ominously named "Avoid mutations". I agree it's a risk, but this is the only way to actually set a TTL other than managing it ourselves, which I think is out of scope.
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.
Note added in ec2050b