Skip to content

Conversation

@azagrebin
Copy link
Contributor

@azagrebin azagrebin commented Apr 8, 2020

What is the purpose of the change

Concurrent TaskSlotTable access in the unstable test

The test called taskSlotTable.allocateSlot from the test main thread,
concurrently with taskSlotTable.createSlotReport while trying to register
RM in the main TM thread. This silently failed the RM registration in TM.runAsync.
As a result, RM.notifySlotAvailable was not called in TM.
The taskSlotTable is not thread-safe and must be accessed only from the main RPC thread of TM.

Failure in establishResourceManagerConnection

Failure of TaskExecutor#establishResourceManagerConnection is not expected.
It completely breaks the connection mechanism to RM in TM.
As a hotfix, the PR suggests to log it on error level at least.
Alternatively, we can consider calling TM.onFatalError as a follow-up.

Brief change log

The PR refactors the test to wait properly for RM registration
and allocate slots through gateway in TM thread.
The PR also uses proper testing RM/JM instead of mocks.

Verifying this change

To verify, the test has been looped locally 30k times.

The test called taskSlotTable.allocateSlot from the test main thread,
concurrently with taskSlotTable.createSlotReport while trying to register
RM in the main TM thread. This silently failed the RM registration in TM.runAsync.
As a result, RM.notifySlotAvailable was not called in TM.

The commmit refactors the test to wait properly for RM registration
and allocate slots through gateway in TM thread.
The commit also uses proper testing RM/JM instead of mocks.

To verify, the test has been looped locally 30k times.
@flinkbot
Copy link
Collaborator

flinkbot commented Apr 8, 2020

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit 475a7a5 (Wed Apr 08 07:45:21 UTC 2020)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.

Details
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Apr 8, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

Copy link
Contributor

@zentol zentol left a comment

Choose a reason for hiding this comment

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

What about the calls to taskSlotTable#tryMarkSlotActive? Similar checks were removed in FLINK-14742.

@azagrebin
Copy link
Contributor Author

Other calls technically happen when the state is synced with the test thread.
On the other hand, it can diverge in future and I replaced them by similar gateway calls which should be enough to check the original intention.

// submit the task without having acknowledge the offered slots
return Either.Left(tmGateway.submitTask(tdd, jobMasterGateway.getFencingToken(), timeout).join());
} catch (CompletionException e) {
return Either.Right(e.getCause());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just let the cause bubble up, possibly enriching it?

You could then use assertThrows for checking the exception.

.build();

try {
// submit the task without having acknowledge the offered slots
Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't necessarily true is it?

Copy link
Contributor

@zentol zentol left a comment

Choose a reason for hiding this comment

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

+1

@azagrebin azagrebin closed this in 280f344 Apr 14, 2020
azagrebin added a commit that referenced this pull request Apr 14, 2020
The test called taskSlotTable.allocateSlot from the test main thread,
concurrently with taskSlotTable.createSlotReport while trying to register
RM in the main TM thread. This silently failed the RM registration in TM.runAsync.
As a result, RM.notifySlotAvailable was not called in TM.

The commmit refactors the test to wait properly for RM registration
and allocate slots through gateway in TM thread.
The commit also uses proper testing RM/JM instead of mocks.

To verify, the test has been looped locally 30k times.

This closes #11667.
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