Skip to content

KAFKA-10079: improve thread-level stickiness#8775

Merged
vvcephei merged 23 commits intoapache:trunkfrom
ableegoldman:10079-HA-for-in-memory-stores
Jun 10, 2020
Merged

KAFKA-10079: improve thread-level stickiness#8775
vvcephei merged 23 commits intoapache:trunkfrom
ableegoldman:10079-HA-for-in-memory-stores

Conversation

@ableegoldman
Copy link
Copy Markdown
Member

@ableegoldman ableegoldman commented Jun 2, 2020

Uses a similar (but slightly different) algorithm as in KAFKA-9987 to produce a maximally sticky -- and perfectly balanced -- assignment of tasks to threads within a single client. This is important for in-memory stores which get wiped out when transferred between threads.

Must be cherrypicked to 2.6

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 2, 2020

Ok to test

Copy link
Copy Markdown
Contributor

@vvcephei vvcephei left a comment

Choose a reason for hiding this comment

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

Thanks @ableegoldman ! It looks good to me overall.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have several new methods, and also this new book-kept collection (consumerToPreviousTaskIds), but no new tests for them in ClientStateTest. Can you add the missing coverage?

The new methods are more a matter of principle; I'm really concerned that we should have good coverage on the bookkeeping aspect of consumerToPreviousTaskIds because I fear future regressions when we have to maintain two data structures in a consistent fashion

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Definitely. I meant to write tests but then I took Luna for a walk and forgot 😄

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 2, 2020

Ok to test

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 2, 2020

Test this please

3 similar comments
@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 2, 2020

Test this please

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 2, 2020

Test this please

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 2, 2020

Test this please

@ableegoldman
Copy link
Copy Markdown
Member Author

Tests failed due to the broken consumer StickyAssignor test that will be fixed via #8786

@ableegoldman ableegoldman force-pushed the 10079-HA-for-in-memory-stores branch from 619cafe to f580e63 Compare June 3, 2020 19:13
Copy link
Copy Markdown
Contributor

@vvcephei vvcephei 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 update, @ableegoldman ; one more question...

}

@Test
public void shouldReturnPreviousStatefulTasksForConsumerInIncreasingLagOrder() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I missed the extra sort on my last review. It really seems like too much fanciness for the ClientState to sort the tasks in lag order. Would it be too messy to move the sort aspect out to the balancing code that needs it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You didn't miss it, I just snuck it in there after your review :P

Sorry, should have called out that I made some more changes. I think that was the only significant logical change though. I'll try pulling the sort out into the assignment code

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 3, 2020

Ok to test

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 3, 2020

Test this please

Copy link
Copy Markdown
Contributor

@vvcephei vvcephei 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 update, @ableegoldman , just one question...

Comment on lines +306 to +307
// If we couldn't compute the task lags due to failure to fetch offsets, just return a flat constant
totalLag = 0L;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this the right constant to represent "we don't know the lag"? Or did I mistake how this is going to be used?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The value itself doesn't matter, just that it's constant across all tasks.

But I'm guessing you meant, why not use the existing UNKNOWN_OFFSET_SUM sentinel, in which case the answer is probably just that I forgot about it. Anyway I did a slight additional refactoring beyond this, just fyi: instead of skipping the lag computation when we fail to fetch offsets, we now always initialize the lags and just pass in the UNKNOWN_OFFSET_SUM for all stateful tasks when the offset fetch fails.

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 4, 2020

Test this please

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 4, 2020

Test this please

1 similar comment
@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 4, 2020

Test this please

@ableegoldman
Copy link
Copy Markdown
Member Author

Java8 failed with
KTableSourceTopicRestartIntegrationTest.shouldRestoreAndProgressWhenTopicNotWrittenToDuringRestoration

Java14 failed with KTableSourceTopicRestartIntegrationTest.shouldRestoreAndProgressWhenTopicWrittenToDuringRestorationWithEosAlphaEnabled

I've seen both of these be flaky already (and frankly am a bit concerned about them...) but I'll see if I can reproduce this locally in case this PR is somehow making them worse

@ableegoldman
Copy link
Copy Markdown
Member Author

200 runs and I can't reproduce either. But it looks like both were previously flaky, and seem unrelated to this PR. Can we kick off tests again?

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 9, 2020

Test this please

5 similar comments
@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 9, 2020

Test this please

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 9, 2020

Test this please

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 9, 2020

Test this please

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jun 9, 2020

Test this please

@vvcephei
Copy link
Copy Markdown
Contributor

Test this please

Copy link
Copy Markdown
Contributor

@vvcephei vvcephei left a comment

Choose a reason for hiding this comment

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

Thanks @ableegoldman !

@vvcephei vvcephei merged commit 0f68dc7 into apache:trunk Jun 10, 2020
vvcephei pushed a commit that referenced this pull request Jun 10, 2020
Uses a similar (but slightly different) algorithm as in KAFKA-9987 to produce a maximally sticky -- and perfectly balanced -- assignment of tasks to threads within a single client. This is important for in-memory stores which get wiped out when transferred between threads.

Reviewers: John Roesler <vvcephei@apache.org>
@vvcephei
Copy link
Copy Markdown
Contributor

Cherry picked to 2.6

@ableegoldman ableegoldman deleted the 10079-HA-for-in-memory-stores branch June 26, 2020 22:39
ijuma added a commit to ijuma/kafka that referenced this pull request Nov 17, 2020
…t-for-generated-requests

* apache-github/trunk: (248 commits)
  KAFKA-10049: Fixed FKJ bug where wrapped serdes are set incorrectly when using default StreamsConfig serdes (apache#8764)
  KAFKA-10027: Implement read path for feature versioning system (KIP-584) (apache#8680)
  KAFKA-10085: correctly compute lag for optimized source changelogs (apache#8787)
  KAFKA-10086: Integration test for ensuring warmups are effective (apache#8818)
  KAFKA-9374: Make connector interactions asynchronous (apache#8069)
  MINOR: reduce sizeInBytes for percentiles metrics (apache#8835)
  KAFKA-10115: Incorporate errors.tolerance with the Errant Record Reporter (apache#8829)
  KAFKA-9216: Enforce that Connect’s internal topics use `compact` cleanup policy (apache#8828)
  KAFKA-9845: Warn users about using config providers with plugin.path property (apache#8455)
  KAFKA-7833: Add missing test (apache#8847)
  KAFKA-9066: Retain metrics for failed tasks (apache#8502)
  KAFKA-9841: Revoke duplicate connectors and tasks when zombie workers return with an outdated assignment (apache#8453)
  KAFKA-9985: Sink connector may exhaust broker when writing in DLQ (apache#8663)
  KAFKA-9441: remove prepareClose() to simplify task management (apache#8833)
  KAFKA-7833: Add Global/StateStore name conflict check (apache#8825)
  KAFKA-9969: Exclude ConnectorClientConfigRequest from class loading isolation (apache#8630)
  KAFKA-9991: Fix flaky unit tests (apache#8843)
  KAFKA-10014; Always try to close all channels in Selector#close (apache#8685)
  KAFKA-10079: improve thread-level stickiness (apache#8775)
  MINOR: Print all removed dynamic members during join complete (apache#8816)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants