Skip to content

KAFKA-9966: add internal assignment listener to stabilize eos-beta upgrade test#8648

Merged
mjsax merged 5 commits into
apache:trunkfrom
ableegoldman:MINOR-assignment-callback-for-integration-tests
May 13, 2020
Merged

KAFKA-9966: add internal assignment listener to stabilize eos-beta upgrade test#8648
mjsax merged 5 commits into
apache:trunkfrom
ableegoldman:MINOR-assignment-callback-for-integration-tests

Conversation

@ableegoldman

Copy link
Copy Markdown
Member

Adds an internal assignment listener interface with a callback that exposes the assignment stability. A useful implementation that tracks the number of stable assignments is available in IntegrationTestUtils, and leveraged to fix the flaky EOSBetaUpgradeTest, but any implementation can be plugged in to meet the specific needs of a test.

@ableegoldman

ableegoldman commented May 12, 2020

Copy link
Copy Markdown
Member Author

Will need to be rebased once pull/8596 is merged, but the PR is ready. Reduced the nearly 100% failure rate of this test on top of the changes in pull/8596 to 0% (that I've seen so far 🙂) @mjsax @vvcephei

edit: this PR alone does not contain all the fixes needed for the eos-beta upgrade test, so I'm leaving it ignored for now. The other set of fixes are included in #8662

We can remove the Ignore annotation in whichever PR gets merged last

@ableegoldman
ableegoldman force-pushed the MINOR-assignment-callback-for-integration-tests branch from 58f5eb2 to c033c3c Compare May 12, 2020 19:36

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we use getLogPrefix() -- our code style always omit the get prefix -- should be just logPrefix() (Similar below for other methods)

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.

I guess I thought there was a reason getXX was used in this class and figured all the methods should conform. Idk. I'll remove the get

@ableegoldman
ableegoldman force-pushed the MINOR-assignment-callback-for-integration-tests branch from c033c3c to 276aae8 Compare May 12, 2020 22:32
@ableegoldman
ableegoldman force-pushed the MINOR-assignment-callback-for-integration-tests branch from 276aae8 to 37bf2a6 Compare May 12, 2020 22:34
}
}

public AssignmentListener assignmentListener() {

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.

This is the only non-cosmetic change in this class, along with the interface added below

private final org.apache.kafka.streams.processor.PartitionGrouper partitionGrouper;
private final String userEndPoint;
private final TaskManager taskManager;
private final StreamsMetadataState streamsMetadataState;

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.

Sorry for all the lines of changes here, but the inconsistent method signatures and object construction was making this class hard to follow. All I'm doing here is making the methods conform to the same style, and moving the construction of any config that isn't needed elsewhere to its getter method. This allows us to remove a lot of these class variables

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we know if the corresponding "getters" are called often or not? I guess the main idea behind having those member variables was to "parse" the config once as it's immutable anyway instead of each time a getter is called?

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.

They are not. We construct the AssignorConfiguration object once in StreamsPartitionAssignor#configure and call the getters immediately afterwards, and only there

final List<KeyValue<KafkaStreams.State, KafkaStreams.State>> expected)
throws Exception {

private void waitForRunning(final List<KeyValue<KafkaStreams.State, KafkaStreams.State>> observed) throws Exception {

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.

This one actually might not be necessary, but I thought it was useful as a sanity check especially since we're trying to access the stores in some places

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed.

@mjsax mjsax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall LGTM.

private final org.apache.kafka.streams.processor.PartitionGrouper partitionGrouper;
private final String userEndPoint;
private final TaskManager taskManager;
private final StreamsMetadataState streamsMetadataState;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we know if the corresponding "getters" are called often or not? I guess the main idea behind having those member variables was to "parse" the config once as it's immutable anyway instead of each time a getter is called?

final List<KeyValue<KafkaStreams.State, KafkaStreams.State>> expected)
throws Exception {

private void waitForRunning(final List<KeyValue<KafkaStreams.State, KafkaStreams.State>> observed) throws Exception {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed.

private void waitForRunning(final List<KeyValue<KafkaStreams.State, KafkaStreams.State>> observed) throws Exception {
waitForCondition(
() -> observed.equals(expected),
() -> observed.get(observed.size() - 1).equals(new KeyValue<>(State.REBALANCING, State.RUNNING)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems this could fail if observed is empty?

Also, could we simplify this? We are only interested in RUNNING state, right? So no need to check the previous state?

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.

True, I'll fix this


@Test
public void shouldThrowExceptionIfApplicationServerConfigPortIsNotAnInteger() {
createDefaultMockTaskManager();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why this change?

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.

If we don't configure the TaskManager then we'll throw (the wrong kind of) exception during configure. Previously this test just happened to pass because we processed the user endpoint before we processed the TaskManager, so we never got to the TaskManager

KeyValue.pair(KafkaStreams.State.REBALANCING, KafkaStreams.State.RUNNING)
)
);
assignmentListener.waitForNextStableAssignment(expectedNumStableAssignments, MAX_WAIT_TIME_MS);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So far we always pass in assignmentListener.numStableAssignments() + 1 -- hence, I am wondering if we need to pass it at all?

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.

Well we need to record it before doing whatever action causes the group to rebalance. But maybe we can do something like prepareForRebalance if that seems easier?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see. Guess it's good as-is.

@mjsax

mjsax commented May 12, 2020

Copy link
Copy Markdown
Member

Retest this please.

@mjsax mjsax added streams tests Test fixes (including flaky tests) labels May 12, 2020

@mjsax mjsax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@mjsax

mjsax commented May 13, 2020

Copy link
Copy Markdown
Member

Retest this please.

1 similar comment
@mjsax

mjsax commented May 13, 2020

Copy link
Copy Markdown
Member

Retest this please.

@ableegoldman

Copy link
Copy Markdown
Member Author

Java 14 passed, Java 8 build failed due to mysterious 17:27:43 ERROR: Error cloning remote repo 'origin' and Java 11 failed due to flaky MirrorConnectorsIntegrationTest.testReplication (reported on ticket)

@mjsax
mjsax merged commit 53875bb into apache:trunk May 13, 2020
Kvicii added a commit to Kvicii/kafka that referenced this pull request May 14, 2020
* 'trunk' of github.com:apache/kafka:
  MINOR: add option to rebuild source for system tests (apache#6656)
  KAFKA-9850 Move KStream#repartition operator validation during Topolo… (apache#8550)
  MINOR: Add a duplicate() method to Message classes (apache#8556)
  KAFKA-9966: add internal assignment listener to stabilize eos-beta upgrade test (apache#8648)
  MINOR: Replace null with an actual value for timestamp field in InsertField SMT unit tests (apache#8649)
  MINOR: Fix ProcessorContext JavaDocs and stream-time computation (apache#8603)
  MINOR: improve tests for TopologyTestDriver (apache#8631)
  KAFKA-9821: consolidate Streams rebalance triggering mechanisms (apache#8596)
  KAFKA-9669; Loosen validation of inner offsets for older message formats (apache#8647)
  KAFKA-8770: KIP-557: Drop idempotent KTable source updates (apache#8254)
  MINOR: Remove allow concurrent test (apache#8641)
jwijgerd pushed a commit to buxapp/kafka that referenced this pull request May 14, 2020
…grade test (apache#8648)

Reviewer: Matthias J. Sax <matthias@confluent.io>
@ableegoldman
ableegoldman deleted the MINOR-assignment-callback-for-integration-tests branch May 15, 2020 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

streams tests Test fixes (including flaky tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants