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

[FLINK-13469][state] Ensure resource used by StateMapSnapshot will be released if snapshot fails #9301

Closed
wants to merge 2 commits into from

Conversation

banmoy
Copy link
Contributor

@banmoy banmoy commented Jul 31, 2019

What is the purpose of the change

Currently, resource used by StateMapSnapshot may not be released by StateTableSnapshot if snapshot fails. For example, If exception happens in StateMapSnapshot#writeState, resources used by current and left StateMapSnapshot can not be released. This PR will fix this problem.

Brief change log

  • make sure all resources are released in StateTableSnapshot#release()
    • CopyOnWriteStateTableSnapshot will check whether the resource is released for each CopyOnWriteStateMapSnapshot in CopyOnWriteStateTableSnapshot#release(), and release them if not
    • NestedMapsStateTableSnapshot need do nothing in NestedMapsStateTableSnapshot#release(). On the one hand, nested snapshot is synchronous, and doesn't hold all state map snapshots which will be used in async part like copy-on-write snapshot. State map snapshot for a key-group will not be created until it's turn to write state of this key group, so there is no resource to need to release except for current state map snapshot. On the other hand, nested state map snapshot actually hold no resource. So NestedMapsStateTableSnapshot need do nothing for release.
  • remove default implementation AbstractStateTableSnapshot#release(). The reasons are as follows:
    • the way to release for the copy-on-write and the nested is very different, so there is no much meaning to provide default implementation
    • force subclass to think about the proper way to release, and make it more safety

Verifying this change

This change added tests and can be verified as follows:

  • Added test CopyOnWriteStateTableTest#testReleaseForSuccessfulSnapshot and CopyOnWriteStateTableTest#testReleaseForFailedSnapshot to validates that resources can be released no matter snapshot is successful or failed

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

@flinkbot
Copy link
Collaborator

flinkbot commented Jul 31, 2019

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 4487019 (Wed Dec 04 14:59:52 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.


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 Jul 31, 2019

CI report:

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

@banmoy
Copy link
Contributor Author

banmoy commented Aug 1, 2019

The failed test is KafkaProducerExactlyOnceITCase.testExactlyOnceCustomOperator which does not use keyed state, so it seems irrelevant to this PR. And FLINK-13527 has been created to track this issue. Retrigger the CI.

@banmoy banmoy changed the title [FLINK-13469][state] Ensure resource used by StateMapSnapshot will be… [FLINK-13469][state] Ensure resource used by StateMapSnapshot will be released if snapshot fails Sep 25, 2019
@banmoy banmoy force-pushed the flink-13469 branch 3 times, most recently from 0643fce to 6b42e10 Compare October 16, 2019 05:00
@banmoy
Copy link
Contributor Author

banmoy commented Oct 16, 2019

@flinkbot run travis

StephanEwen pushed a commit to StephanEwen/flink that referenced this pull request Nov 6, 2019
@asfgit asfgit closed this in 02c4f20 Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants