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

tasks tables in metadata storage are not cleared #6592

Merged
merged 6 commits into from
Nov 22, 2018

Conversation

seoeun25
Copy link
Contributor

@seoeun25 seoeun25 commented Nov 9, 2018

This PR mainly contains:

  1. Remove the older tasks at metastore (druid_tasks) on tasklog cleanup schedule.
  2. Not implement auditlog deletion since auditlogging is deprecated (Deprecate task audit logging #6368 )

.map(entry -> entry.getKey())
.collect(Collectors.toList());

taskIds.stream().forEach(taskId -> tasks.remove(taskId));
Copy link
Member

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);
Copy link
Member

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()));
Copy link
Member

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)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have updated.

@seoeun25
Copy link
Contributor Author

seoeun25 commented Nov 13, 2018

It references the created_date at tasks table since tasklogs table have no created_date column.
It marks @deprecated to getSqlRemoveLogsOlderThan since tasklogs deprecated.

* Remove the tasks created order than the given createdTime.
*
* @param timestamp timestamp to check the {@code created_date} of tasks
*/
Copy link
Member

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
   */

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);
Copy link
Member

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())
Copy link
Member

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.

@QiuMM
Copy link
Member

QiuMM commented Nov 13, 2018

It marks @deprecated to getSqlRemoveLogsOlderThan since tasklogs deprecated.

@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.

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
*/

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.

@gianm
Copy link
Contributor

gianm commented Nov 13, 2018

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.

@gianm gianm added this to the 0.13.1 milestone Nov 13, 2018
@seoeun25
Copy link
Contributor Author

This commit contains:

  1. change the variable name and comment.
  2. update the doc to druid.indexer.logs.kill.enabled.

Copy link
Contributor

@jihoonson jihoonson left a 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());
Copy link
Contributor

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(
Copy link
Contributor

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
Copy link
Contributor

@seoeun25 Auditlog has been deprecated, not tasklogs.

@QiuMM, it's quite confusing, but @seoeun25 is correct. tasklogs is the table for task audit logging which is deprecated now. The audit table is for auditing rule changes.

@QiuMM
Copy link
Member

QiuMM commented Nov 20, 2018

@jihoonson @seoeun25 oops, I had not checked it carefully, sorry.

@seoeun25
Copy link
Contributor Author

@QiuMM @surekhasaharan @jihoonson @gianm Thanks for the review. Addressed comments and updated doc more detailed.

Copy link
Contributor

@jihoonson jihoonson left a comment

Choose a reason for hiding this comment

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

@QiuMM no worries!

@seoeun25 thanks for the quick fix! I left one more comment.

public void removeTasksOlderThan(final long timestamp)
{
DateTime dateTime = DateTimes.utc(timestamp);
log.info("Deleting tasks older than [%s] and inactive at metastore.", dateTime.toString());
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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|

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. "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your comment !

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|

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"

@seoeun25
Copy link
Contributor Author

@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.
*
Copy link
Member

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.
Copy link
Member

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.

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|
Copy link
Member

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.

|`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|
Copy link
Member

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....

Copy link
Contributor

@jihoonson jihoonson left a 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.

@seoeun25
Copy link
Contributor Author

@QiuMM Thanks for the comments! updated doc.

@QiuMM QiuMM merged commit 22a5bf9 into apache:master Nov 22, 2018
@seoeun25 seoeun25 deleted the apache-6579 branch November 22, 2018 05:14
jihoonson pushed a commit to implydata/druid-public that referenced this pull request Dec 13, 2018
…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
seoeun25 added a commit to seoeun25/incubator-druid that referenced this pull request Jan 10, 2020
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants