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

Don't update segment metadata if archive doesn't move anything #3476

Merged
merged 7 commits into from
Dec 1, 2016

Conversation

drcrallen
Copy link
Contributor

@drcrallen drcrallen commented Sep 21, 2016

Fixes #3475

Expands the behavior of the archiver to handle when things don't actually move. In such a scenario metadata segment update actions are not attempted.

If an Archiver implementation does not honor the new interface contract, then the prior behavior is still preserved.

@drcrallen drcrallen added this to the 0.9.3 milestone Sep 21, 2016
@drcrallen
Copy link
Contributor Author

I totally didn't mean to push this to a druid-io branch, sorry about that.

@drcrallen
Copy link
Contributor Author

Odd failure:

Tests run: 12, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.605 sec <<< FAILURE! - in io.druid.server.lookup.PollingLookupTest
testApplyAfterDataChange[1](io.druid.server.lookup.PollingLookupTest)  Time elapsed: 0.133 sec  <<< FAILURE!
java.lang.AssertionError: non-null check expected:<bar> but was:<null>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:743)
    at org.junit.Assert.assertEquals(Assert.java:118)
    at io.druid.server.lookup.PollingLookupTest.assertMapLookup(PollingLookupTest.java:205)
    at io.druid.server.lookup.PollingLookupTest.testApplyAfterDataChange(PollingLookupTest.java:148)

https://travis-ci.org/druid-io/druid/jobs/161527673

@drcrallen drcrallen closed this Sep 21, 2016
@drcrallen drcrallen reopened this Sep 21, 2016
@drcrallen
Copy link
Contributor Author

Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 67.912 sec <<< FAILURE! - in io.druid.curator.announcement.AnnouncerTest
testSanity(io.druid.curator.announcement.AnnouncerTest)  Time elapsed: 61.081 sec  <<< ERROR!
java.lang.Exception: test timed out after 60000 milliseconds
    at sun.misc.Unsafe.park(Native Method)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1037)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1328)
    at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:277)
    at org.apache.curator.test.Timing.awaitLatch(Timing.java:120)
    at io.druid.curator.announcement.AnnouncerTest.testSanity(AnnouncerTest.java:101)

https://travis-ci.org/druid-io/druid/jobs/161663853

different failure

@drcrallen drcrallen closed this Sep 21, 2016
@drcrallen drcrallen reopened this Sep 21, 2016
@drcrallen
Copy link
Contributor Author

Tests run: 12, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.685 sec <<< FAILURE! - in io.druid.server.lookup.PollingLookupTest
testApplyAfterDataChange[1](io.druid.server.lookup.PollingLookupTest)  Time elapsed: 0.223 sec  <<< FAILURE!
java.lang.AssertionError: non-null check expected:<bar> but was:<null>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:743)
    at org.junit.Assert.assertEquals(Assert.java:118)
    at io.druid.server.lookup.PollingLookupTest.assertMapLookup(PollingLookupTest.java:205)
    at io.druid.server.lookup.PollingLookupTest.testApplyAfterDataChange(PollingLookupTest.java:148)

failed again https://travis-ci.org/druid-io/druid/jobs/161700091

*
* @throws SegmentLoadingException on error
*/
DataSegment archive(DataSegment segment) throws SegmentLoadingException;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe annotate with @javax.annotation.Nullable? This will make IDE to warn you about using the object, returned from this method, without null check.

*
* @throws SegmentLoadingException on error
*/
DataSegment restore(DataSegment segment) throws SegmentLoadingException;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe annotate with @javax.annotation.Nullable?


// Move segments
for (DataSegment segment : unusedSegments) {
List<DataSegment> restoredSegments = Lists.newLinkedList();
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 LinkedList is pointless here. It's not a performance-critical place; but there should always be a reason to use LinkedList rather than default ArrayList. When reader sees LinkedList, he spends mental cycles trying to understand, why it is used here. It's confusing when there is no apparent reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I don't remember why that was here.

final DataSegment restored = toolbox.getDataSegmentArchiver().restore(segment);
if (restored == null) {
log.info("Segment [%s] did not move, not updating metadata", segment);
} else {
restoredSegments.add(toolbox.getDataSegmentArchiver().restore(segment));
Copy link
Member

Choose a reason for hiding this comment

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

Maybe should use the restored variable here rather than computing toolbox.getDataSegmentArchiver().restore(segment) again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes we should, fixing

// Move segments
for (DataSegment segment : unusedSegments) {
final DataSegment restored = toolbox.getDataSegmentArchiver().restore(segment);
if (restored == null) {
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with ArchiveTask, maybe restored != null branch should go first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@@ -22,18 +22,17 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;

import com.metamx.common.ISE;
Copy link
Member

Choose a reason for hiding this comment

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

Use new package, since java-util has moved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@leventov
Copy link
Member

leventov commented Nov 2, 2016

👍 after Travis

@fjy
Copy link
Contributor

fjy commented Nov 11, 2016

👍

* @throws SegmentLoadingException on error
*/
@Nullable
DataSegment archive(DataSegment segment) throws SegmentLoadingException;
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of returning null, perhaps a nicer API would be to return an equivalent object. Then callers don't need to deal with potentially null returns. If a caller wants to know if anything was actually done, they could check retVal.equals(segment) rather than retVal != null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's pretty challenging since loadSpec is just a Map<String, Object> which may have whatever junk in it. I opted for this way of doing it so that the implementation can make the determination on if the segment was moved or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also see #3287 and #3286 for semi-related

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, I forgot DataSegment identity is based around the segment identifier. OK then in that case what I said is nonsense.

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.

👍

@gianm gianm merged commit 27ab23e into master Dec 1, 2016
@gianm gianm deleted the smarterArchiver branch December 1, 2016 15:49
@clambertus clambertus unassigned fjy and gianm Jul 6, 2018
seoeun25 pushed a commit to seoeun25/incubator-druid that referenced this pull request Feb 25, 2022
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.

4 participants