-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
tasks tables in metadata storage are not cleared #6592
Conversation
core/src/main/java/org/apache/druid/metadata/MetadataStorageActionHandler.java
Outdated
Show resolved
Hide resolved
.map(entry -> entry.getKey()) | ||
.collect(Collectors.toList()); | ||
|
||
taskIds.stream().forEach(taskId -> tasks.remove(taskId)); |
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.
Just taskIds.forEach(tasks::remove);
would be ok.
* | ||
* @param createdTime datetime to check the {@code created_date} of tasks | ||
*/ | ||
void removeTasksBefore(DateTime createdTime); |
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.
maybe change to void removeTasksOlderThan(long timestamp)
to keep consistent with TaskLogKiller#killOlderThan.
@@ -68,6 +73,7 @@ public void run() | |||
{ | |||
try { | |||
taskLogKiller.killOlderThan(System.currentTimeMillis() - config.getDurationToRetain()); | |||
taskStorage.removeTasksBefore(DateTimes.nowUtc().minus(config.getDurationToRetain())); |
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.
same, change to taskStorage.removeTasksOlderThan(System.currentTimeMillis() - config.getDurationToRetain()))
for consistency.
@@ -439,6 +439,26 @@ public Void withHandle(Handle handle) | |||
); | |||
} | |||
|
|||
@Override | |||
public void removeTasksBefore(final DateTime createdTime) |
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.
please clean up the tasklogs table at the same time.
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.
Have updated.
It references the created_date at tasks table since tasklogs table have no created_date column. |
* Remove the tasks created order than the given createdTime. | ||
* | ||
* @param timestamp timestamp to check the {@code created_date} of tasks | ||
*/ |
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.
I think the comment like below would be better:
/**
* Remove the tasks created order than the given timestamp.
*
* @param timestamp timestamp in milliseconds
*/
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.
Agree, please change "order" to "older" here as well.
{ | ||
connector.retryWithHandle( | ||
(HandleCallback<Void>) handle -> { | ||
DateTime createdTime = DateTimes.utc(timestamp); |
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.
I do not like this variable name, it's a time point not a created time. Maybe DateTime dateTime = DateTimes.utc(timestamp);
entryTable | ||
) | ||
) | ||
.bind("created_date", createdTime.toString()) |
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.
Same, change created_date
to another name.
@seoeun25 Auditlog has been deprecated, not tasklogs. |
@@ -130,6 +130,13 @@ void insert( | |||
*/ | |||
void removeLock(long lockId); | |||
|
|||
/** | |||
* Remove the tasks created order than the given createdTime. |
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: change "order" or "older". Or may be better way is "Remove the tasks with timestamp older than given timestamp
* Remove the tasks created order than the given createdTime. | ||
* | ||
* @param timestamp timestamp to check the {@code created_date} of tasks | ||
*/ |
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.
Agree, please change "order" to "older" here as well.
It looks like this is adding new behavior (deleting old tasks) to a pre-existing config (druid.indexer.logs.kill.durationToRetain). Is that right? What's the default for these? I'm just thinking about whether people will be surprised by the new behavior. At any rate, I'll add a "release notes" label so we can call out what would change, if anything. This patch should also include a doc update. |
This commit contains:
|
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.
@seoeun25 thanks for the contribution! I left a few trivial comments. Also, would you please add more detailed docs which describe that druid.indexer.logs.kill.enabled
will update the tasks
and tasklogs
tables as well?
connector.retryWithHandle( | ||
(HandleCallback<Void>) handle -> { | ||
DateTime dateTime = DateTimes.utc(timestamp); | ||
log.info("Deleting tasks older than [%s] and inactive at metastore.", dateTime.toString()); |
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.
I think it's better to add a log in the caller than here because this will be printed per retry.
DateTime dateTime = DateTimes.utc(timestamp); | ||
log.info("Deleting tasks older than [%s] and inactive at metastore.", dateTime.toString()); | ||
handle.createStatement( | ||
StringUtils.format( |
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.
I guess this is not needed?
@jihoonson @seoeun25 oops, I had not checked it carefully, sorry. |
@QiuMM @surekhasaharan @jihoonson @gianm Thanks for the review. Addressed comments and updated doc more detailed. |
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.
public void removeTasksOlderThan(final long timestamp) | ||
{ | ||
DateTime dateTime = DateTimes.utc(timestamp); | ||
log.info("Deleting tasks older than [%s] and inactive at metastore.", dateTime.toString()); |
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.
Sorry, I was not clear. I think it's better to remove log
from this class (which shouldn't be part of this PR) because it's not very useful. Logging should give us detailed context about what's happening, but a simple I will delete some tasks from metadata
message is not much useful I think. Rather, it looks good to me to print logs in the caller of this method, like in TaskAutoCleaner
.
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.
I agree. I think it's better to remove log
.
docs/content/configuration/index.md
Outdated
Caution: Automatic log file deletion typically works based on log file modification timestamp on the backing store, so large clock skews between druid nodes and backing store nodes might result in un-intended behavior. | ||
|
||
|Property|Description|Default| | ||
|--------|-----------|-------| | ||
|`druid.indexer.logs.kill.enabled`|Boolean value for whether to enable deletion of old task logs. |false| | ||
|`druid.indexer.logs.kill.enabled`|Boolean value for whether to enable deletion of old task logs. If set to true, overlord will submit tasks periodically based on `delay` specified. These kill tasks will delete task logs from log directory and tasks and tasklogs table in metadata storage except for the last `durationToRetain` period. |false| |
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.
How about "If set to true, overlord will submit kill tasks periodically based on delay
specified, which will delete task logs from the log directory as well as tasks and tasklogs table in metadata storage except for tasks created in the last durationToRetain
period. "
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.
Thanks for your comment !
docs/content/configuration/index.md
Outdated
Caution: Automatic log file deletion typically works based on log file modification timestamp on the backing store, so large clock skews between druid nodes and backing store nodes might result in un-intended behavior. | ||
|
||
|Property|Description|Default| | ||
|--------|-----------|-------| | ||
|`druid.indexer.logs.kill.enabled`|Boolean value for whether to enable deletion of old task logs. |false| | ||
|`druid.indexer.logs.kill.enabled`|Boolean value for whether to enable deletion of old task logs. If set to true, overlord will submit tasks periodically based on `delay` specified. These kill tasks will delete task logs from log directory and tasks and tasklogs table in metadata storage except for the last `durationToRetain` period. |false| | ||
|`druid.indexer.logs.kill.durationToRetain`| Required if kill is enabled. In milliseconds, task logs to be retained created in last x milliseconds. |None| |
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.
If this behavior is also getting changed, please add doc here as well, something like "task logs and task-related metadata storage tables to be retained created in last x milliseconds"
@jihoonson @surekhasaharan Thanks for the review. remove redundant log and update doc more detailed. |
@@ -130,6 +130,13 @@ void insert( | |||
*/ | |||
void removeLock(long lockId); | |||
|
|||
/** | |||
* Remove the tasks with timestamp older than given timestamp. | |||
* |
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.
Remove the tasks created older than the given timestamp.
would be better.
@@ -525,13 +525,13 @@ If you are running the indexing service in remote mode, the task logs must be st | |||
|--------|-----------|-------| | |||
|`druid.indexer.logs.type`|Choices:noop, s3, azure, google, hdfs, file. Where to store task logs|file| | |||
|
|||
You can also configure the Overlord to automatically retain the task logs only for last x milliseconds by configuring following additional properties. | |||
You can also configure the Overlord to automatically retain the task logs in log directory and task-related metadata storage tables only for last x milliseconds by configuring following additional properties. | |||
Caution: Automatic log file deletion typically works based on log file modification timestamp on the backing store, so large clock skews between druid nodes and backing store nodes might result in un-intended behavior. |
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.
...in log directory and entries in task-related metadata storage tables...
would be better.
docs/content/configuration/index.md
Outdated
Caution: Automatic log file deletion typically works based on log file modification timestamp on the backing store, so large clock skews between druid nodes and backing store nodes might result in un-intended behavior. | ||
|
||
|Property|Description|Default| | ||
|--------|-----------|-------| | ||
|`druid.indexer.logs.kill.enabled`|Boolean value for whether to enable deletion of old task logs. |false| | ||
|`druid.indexer.logs.kill.durationToRetain`| Required if kill is enabled. In milliseconds, task logs to be retained created in last x milliseconds. |None| | ||
|`druid.indexer.logs.kill.enabled`|Boolean value for whether to enable deletion of old task logs. If set to true, overlord will submit kill tasks periodically based on `delay` specified, which will delete task logs from the log directory as well as tasks and tasklogs table in metadata storage except for tasks created in the last `durationToRetain` period. |false| |
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.
I think
....based on `druid.indexer.logs.kill.delay` specified, which will delete task logs from the log directory as well as tasks and tasklogs table entries in metadata storage except for tasks created in the last `druid.indexer.logs.kill.durationToRetain` period.
would be better.
docs/content/configuration/index.md
Outdated
|`druid.indexer.logs.kill.enabled`|Boolean value for whether to enable deletion of old task logs. |false| | ||
|`druid.indexer.logs.kill.durationToRetain`| Required if kill is enabled. In milliseconds, task logs to be retained created in last x milliseconds. |None| | ||
|`druid.indexer.logs.kill.enabled`|Boolean value for whether to enable deletion of old task logs. If set to true, overlord will submit kill tasks periodically based on `delay` specified, which will delete task logs from the log directory as well as tasks and tasklogs table in metadata storage except for tasks created in the last `durationToRetain` period. |false| | ||
|`druid.indexer.logs.kill.durationToRetain`| Required if kill is enabled. In milliseconds, task logs and task-related metadata storage tables to be retained created in last x milliseconds. |None| |
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.
Same, ...task logs and entries in task-related....
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.
LGTM other than @QiuMM's comments.
@QiuMM Thanks for the comments! updated doc. |
…he#6592) * tasks tables in metadata storage are not cleared * address comments. remove tasklogs and revert obsolete changes * address comments. change comment and update doc. * address comments. update doc more detailed * address comments. remove redundant log and update doc more detailed. * address comments. update document
…age are not cleared 6592) * tasks tables in metadata storage are not cleared * address comments. remove tasklogs and revert obsolete changes * address comments. change comment and update doc. * address comments. update doc more detailed * address comments. remove redundant log and update doc more detailed. * address comments. update document
This PR mainly contains: