Skip to content

Conversation

@KarmaGYZ
Copy link
Contributor

What is the purpose of the change

The State TTL RocksDb/file backend tests now contains thread safety issue during the call of MonotonicTTLTimeProvider. This PR harden the thread safety of that class.

Brief change log

Replace the freeze/unfreeze function with doWithFrozenTime, which run user defined function in synchronize state.

Verifying this change

This change added tests and can be verified as follows:

  • Set taskmanager.numberOfTaskSlots to PARALLELISM and run State TTL RocksDb/file backend end to end test.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

cc @azagrebin

@flinkbot
Copy link
Collaborator

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 54ecee6 (Thu Nov 28 13:48:06 UTC 2019)

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 Nov 28, 2019

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

@azagrebin azagrebin 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 opening the PR @KarmaGYZ
I left a comment to address before merging this.

return lastReturnedProcessingTime;
}
return getCurrentTimestamp();
return action.apply(getCurrentTimestamp());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we still need to freeze and unfreeze time before and after this call asserting timestampAfterUpdate == timestampBeforeUpdate but now in a thread safe manner. Otherwise, this class does nothing and we again will have the problems with time discrepancies during verification which was the reason why we introduced the time freezing before. Looks like we do not really need to change the existing code too much, only introduce doWithFrozenTime and freeze/unfreeze methods can be private now w/o locking internally.

Also, doWithFrozenTime can be annotated with @GuardedBy("lock").

Sorry, I guess my comment on Jira did not have the full code.

@KarmaGYZ
Copy link
Contributor Author

Thanks for the review @azagrebin . Addressed.

@KarmaGYZ
Copy link
Contributor Author

@flinkbot run travis


@GuardedBy("lock")
static long freeze() {
static <T, E extends Throwable> T doWithFrozenTime(FunctionWithException<Long, T, E> action) throws E {
Copy link
Contributor

@azagrebin azagrebin Dec 10, 2019

Choose a reason for hiding this comment

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

I moved this method up because in our code style we try to adhere to the following method order in the class:


static fields

non-static fields

constructor1() { constructor2() }

constructor2() { }

// non static methods:

method1() { method2() }

method2() { method3() }

method3() { }

// static methods:

staticMethod1() { staticMethod2(); staticMethod3(); }

staticMethod2() { }

staticMethod3() { }

inner classes

embedded static classes

...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the explanation! I'll follow this style guide from now on.

Copy link
Contributor

@azagrebin azagrebin 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 addressing the comments @KarmaGYZ
LGTM, merging this once Travis gives again green light

@azagrebin azagrebin force-pushed the FLINK-14951 branch 2 times, most recently from 98b5328 to c6eeebb Compare December 10, 2019 16:23
return lastReturnedProcessingTime;
}
final long timestampBeforeUpdate = freeze();
T result = action.apply(timestampBeforeUpdate);
Copy link
Contributor

Choose a reason for hiding this comment

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

I fixed one more thing here. We have to use the frozen time timestampBeforeUpdate because if we use getCurrentTimestamp it will change the frozen time and fail checkState later.

@azagrebin azagrebin merged commit 2c11291 into apache:master Dec 11, 2019
@azagrebin
Copy link
Contributor

merged into master by 2c11291

@KarmaGYZ KarmaGYZ deleted the FLINK-14951 branch January 11, 2021 02:21
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