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

Fix NPE in compactionTask #5613

Merged
merged 6 commits into from Apr 13, 2018
Merged

Conversation

jihoonson
Copy link
Contributor

@jihoonson jihoonson commented Apr 9, 2018

Fixes #5611.


This change is Reviewable

@jihoonson
Copy link
Contributor Author

I also changed the constructor of Metadata which is a PublicApi. I will revert this change when merging this into 0.12.1.

@fjy fjy modified the milestones: 0.12.1, 0.13.0 Apr 10, 2018
@pdeva
Copy link
Contributor

pdeva commented Apr 10, 2018

is there a reason why this is no longer included for 0.12.1?

@fjy
Copy link
Contributor

fjy commented Apr 11, 2018

@pdeva we'll backport it

@gianm
Copy link
Contributor

gianm commented Apr 11, 2018

Wait, if there's going to be a backport, then this issue should be milestoned as 0.12.1.

@jihoonson, as the author do you think it make sense to backport it? (i.e. does the bug exist in 0.12.0 and is the fix relatively low risk as far as unrelated code is concerned)

I'll unmilestone it until a decision is made.

@gianm gianm removed this from the 0.13.0 milestone Apr 11, 2018
@jihoonson
Copy link
Contributor Author

@gianm I think this is worthwhile to backport. I understand your concern about unrelated code changes, but they will be reverted when backporting to 0.12 because unrelated code changes are mostly to make the Metadata immutable which is a PublicApi class. This shouldn't be included in minor releases.

@jihoonson
Copy link
Contributor Author

If you think it would be better to split this PR into two PRs for fixing NPE in compactionTask and making Metadata immutable, I'll do it.

@gianm
Copy link
Contributor

gianm commented Apr 11, 2018

It sounds like a good backport candidate to me then.

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

Thanks for the fix Jihoon. You mentioned that you wanted to backport this to 0.12.0 without the Metadata changes (since they aren't compatible) - that sounds good to me.

This PR should be marked 'incompatible' so I will do so. The backport should not be incompatible though.

@@ -292,9 +302,14 @@ private static DataSchema createDataSchema(
final List<QueryableIndex> queryableIndices = loadSegments(timelineSegments, segmentFileMap, indexIO);

// find merged aggregators
for (QueryableIndex index : queryableIndices) {
if (index.getMetadata() == null) {
throw new RE("Index metadata doesn't exist for interval[%s]", index.getDataInterval());
Copy link
Contributor

Choose a reason for hiding this comment

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

The error message should really include the segment identifier. Imagine the poor user that gets this error and can't figure out which segment to look at.

Perhaps we can keep it along with the QueryableIndex using a Pair or a small static holder class returned from loadSegments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Added segment identifier.

@@ -304,7 +319,10 @@ private static DataSchema createDataSchema(

// find granularity spec
// set rollup only if rollup is set for all segments
final boolean rollup = queryableIndices.stream().allMatch(index -> index.getMetadata().isRollup());
final boolean rollup = queryableIndices.stream().allMatch(index -> {
final Boolean isRollup = index.getMetadata().isRollup(); // We have already done null check
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably say // We have already done null check on index.getMetadata() (since Rollup could still be null, and the comment is vague about that)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to // We have already checked getMetadata() doesn't return null.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even better!

result = 31 * result + (queryGranularity != null ? queryGranularity.hashCode() : 0);
result = 31 * result + (rollup != null ? rollup.hashCode() : 0);
return result;
return Objects.hash(container, Arrays.hashCode(aggregators), timestampSpec, queryGranularity, rollup);
Copy link
Contributor

Choose a reason for hiding this comment

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

equals could be simplified too (using Objects.equals and Arrays.equals)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jihoonson
Copy link
Contributor Author

@gianm thanks. Addressed your comments.

@gianm
Copy link
Contributor

gianm commented Apr 13, 2018

Milestoning this as 0.13.0 since not all of it will be backported. The backport should be milestoned as 0.12.1 though.

@gianm gianm added this to the 0.13.0 milestone Apr 13, 2018
Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

LGTM

@gianm gianm merged commit f349e03 into apache:master Apr 13, 2018
@gianm
Copy link
Contributor

gianm commented Apr 13, 2018

@jihoonson please go ahead with the backport of non-compatibility-breaking changes.

sathishsri88 pushed a commit to sathishs/druid that referenced this pull request May 8, 2018
* Fix NPE in compactionTask

* more annotations for metadata

* better error message for empty input

* fix build

* revert some null checks

* address comments
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.

None yet

4 participants