Skip to content

Fix bug in TaskStorageQueryAdapter#16750

Merged
kfaraz merged 5 commits intoapache:masterfrom
kfaraz:fix_task_storage_query_adapter
Jul 17, 2024
Merged

Fix bug in TaskStorageQueryAdapter#16750
kfaraz merged 5 commits intoapache:masterfrom
kfaraz:fix_task_storage_query_adapter

Conversation

@kfaraz
Copy link
Copy Markdown
Contributor

@kfaraz kfaraz commented Jul 17, 2024

Description

1. Bug in TaskStorageQueryAdapter

#15377 introduced a change to fetch task payloads from memory.

But it keeps a reference to the TaskQueue when TaskStorageQueryAdapter is being constructed.

The TaskQueue object is recreated upon every leader election.
So, effectively, if a node becomes a leader again, it would use the older instance of the TaskQueue
from when it had first become the leader.

But that old instance of TaskQueue would not have information of new tasks and would eventually fall back
to fetching stuff from metadata storage, rendering the caching layer useless.

Also, memory leaks.

2. Broken master

#16309 removed the method TaskAction.isAudited(). Some task actions still have this method causing compilation failure.

Changes

  • Do not hold a reference to TaskQueue in TaskStorageQueryAdapter
  • Use TaskStorage instead of TaskStorageQueryAdapter in IndexerMetadataStorageAdapter
  • Rename TaskStorageQueryAdapter to TaskQueryTool
  • Fix newly added task actions RetrieveUpgradedFromSegmentIds and RetrieveUpgradedToSegmentIds
    by removing isAudited method.

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.


TaskStorageQueryAdapter taskStorageQueryAdapter = EasyMock.createMock(TaskStorageQueryAdapter.class);
EasyMock.expect(taskStorageQueryAdapter.getStatus("task"))
TaskQueryTool taskQueryTool = EasyMock.createMock(TaskQueryTool.class);

Check notice

Code scanning / CodeQL

Possible confusion of local and field

Potentially confusing name: method [testGetMultipleTaskStatuses_absentTaskQueue](1) also refers to field [taskQueryTool](2) (as this.taskQueryTool).
@kfaraz
Copy link
Copy Markdown
Contributor Author

kfaraz commented Jul 17, 2024

Marked as dev blocker since master branch is broken after merging #16309

Note: The original bug fix in this PR does not address the broken master branch.
But the fix for broken master has been included here as well as it only required removing an unused method.

Copy link
Copy Markdown
Contributor

@AmatyaAvadhanula AmatyaAvadhanula left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks, @kfaraz

@AmatyaAvadhanula
Copy link
Copy Markdown
Contributor

AmatyaAvadhanula commented Jul 17, 2024

Marked as dev blocker since master branch is broken after merging #16309

This seems misleading as the bug in TaskStorageQueryAdapter doesn't break master. Could you please edit the PR description accordingly?

@kfaraz kfaraz merged commit 89066b7 into apache:master Jul 17, 2024
@kfaraz kfaraz deleted the fix_task_storage_query_adapter branch July 17, 2024 17:47
@kfaraz
Copy link
Copy Markdown
Contributor Author

kfaraz commented Jul 17, 2024

Thanks for the quick review, @AmatyaAvadhanula !

edgar2020 pushed a commit to edgar2020/druid that referenced this pull request Jul 19, 2024
Changes:
- Do not hold a reference to `TaskQueue` in `TaskStorageQueryAdapter`
- Use `TaskStorage` instead of `TaskStorageQueryAdapter` in `IndexerMetadataStorageAdapter`
- Rename `TaskStorageQueryAdapter` to `TaskQueryTool`
- Fix newly added task actions `RetrieveUpgradedFromSegmentIds` and `RetrieveUpgradedToSegmentIds`
by removing `isAudited` method.
edgar2020 pushed a commit to edgar2020/druid that referenced this pull request Jul 19, 2024
Changes:
- Do not hold a reference to `TaskQueue` in `TaskStorageQueryAdapter`
- Use `TaskStorage` instead of `TaskStorageQueryAdapter` in `IndexerMetadataStorageAdapter`
- Rename `TaskStorageQueryAdapter` to `TaskQueryTool`
- Fix newly added task actions `RetrieveUpgradedFromSegmentIds` and `RetrieveUpgradedToSegmentIds`
by removing `isAudited` method.
sreemanamala pushed a commit to sreemanamala/druid that referenced this pull request Aug 6, 2024
Changes:
- Do not hold a reference to `TaskQueue` in `TaskStorageQueryAdapter`
- Use `TaskStorage` instead of `TaskStorageQueryAdapter` in `IndexerMetadataStorageAdapter`
- Rename `TaskStorageQueryAdapter` to `TaskQueryTool`
- Fix newly added task actions `RetrieveUpgradedFromSegmentIds` and `RetrieveUpgradedToSegmentIds`
by removing `isAudited` method.
@kfaraz kfaraz added this to the 31.0.0 milestone Oct 4, 2024
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.

3 participants