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-25329][runtime] Support memory execution graph store in session cluster #18360

Conversation

FangYongs
Copy link
Contributor

What is the purpose of the change

This PR aims to support memory execution graph store in session cluster

Brief change log

    • Improve MemoryExecutionGraphInfoStore to support expiration time and maximum capacity
    • Support memory and file execution graph store in SessionClusterEntrypoint

Verifying this change

This change added tests and can be verified as follows:

    • Add MemoryExecutionGraphInfoStoreTest that test the methods in MemoryExecutionGraphInfoStore

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

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

Documentation

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

@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 ff1d101 (Fri Jan 14 05:19:58 UTC 2022)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!
  • This pull request references an unassigned Jira ticket. According to the code contribution guide, tickets need to be assigned before starting with the implementation work.

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 Jan 14, 2022

CI report:

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

@FangYongs
Copy link
Contributor Author

@flinkbot run azure

@FangYongs
Copy link
Contributor Author

@rmetzger Can you please help to review this PR when you're free, thanks

@KarmaGYZ
Copy link
Contributor

Thanks for the PR, @zjureel . I think it is a valid improvement. Regarding the implementation, I think we can simply introduce a config option "jobstore.flush-to-disk" to FileExecutionGraphInfoStore instead of introducing a new one, for deduplication.

@FangYongs FangYongs force-pushed the FLINK_25329_support_memory_store_in_session branch 2 times, most recently from 93ceba0 to b10b4c3 Compare January 24, 2022 07:50
@FangYongs
Copy link
Contributor Author

Thanks @KarmaGYZ I have updated the codes and add a config option jobstore.flush-to-disk in FileExecutionGraphInfoStore instead of a memory store

Copy link
Contributor

@KarmaGYZ KarmaGYZ 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 PR @zjureel . It LGTM except for some minor comments. Please address them and squash your commits.

@FangYongs
Copy link
Contributor Author

Thanks @KarmaGYZ , I have updated the doc and comments in FileExecutionGraphInfoStore and FileExecutionGraphInfoStoreTest

@FangYongs FangYongs force-pushed the FLINK_25329_support_memory_store_in_session branch from 65220a8 to 56fee29 Compare January 25, 2022 07:41
@KarmaGYZ
Copy link
Contributor

@zjureel I think we need also ignore the maximumCacheSizeBytes in this case. However, there might be a lot of "if...else" in FileExecutionGraphInfoStore. Maybe we should return to a separate MemoryExecutionGraphInfoStore. Sorry for the inconvenience.

@FangYongs FangYongs force-pushed the FLINK_25329_support_memory_store_in_session branch 3 times, most recently from 6915706 to 5d6e58a Compare January 30, 2022 05:01
@FangYongs
Copy link
Contributor Author

Thanks @KarmaGYZ , it doesn't matter and I have used MemoryExecutionGraphInfoStore, you can review the codes again when you're free, thanks :)

Comment on lines 334 to 335
"'Memory': the memory job store keeps the archived execution graphs in memory and "
+ " it may cause FullGC or OOM when there are too many graphs"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"'Memory': the memory job store keeps the archived execution graphs in memory and "
+ " it may cause FullGC or OOM when there are too many graphs"))
"'Memory': the memory job store keeps the archived execution graphs in memory. You "
+ "may need to limit the %s to mitigate FullGC or OOM when there are too many graphs",
code(JOB_STORE_MAX_CAPACITY.key())))

*/
public class MemoryExecutionGraphInfoStore implements ExecutionGraphInfoStore {

private final Map<JobID, ExecutionGraphInfo> serializableExecutionGraphInfos = new HashMap<>(4);
private final Map<JobID, ExecutionGraphInfo> serializableExecutionGraphInfos =
new ConcurrentHashMap<>(4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
new ConcurrentHashMap<>(4);
new ConcurrentHashMap<>();

/** Capacity of the memory store, 0 means unlimited. */
private final int maximumCapacity;

private final ScheduledExecutor scheduledExecutor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private final ScheduledExecutor scheduledExecutor;
@Nullable private final ScheduledExecutor scheduledExecutor;

private final int maximumCapacity;

private final ScheduledExecutor scheduledExecutor;
private ScheduledFuture<?> cleanupFuture;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private ScheduledFuture<?> cleanupFuture;
@Nullable private ScheduledFuture<?> cleanupFuture;

new ConcurrentHashMap<>(4);

/** Job id with creation timestamp. */
private final Queue<JobGraphTimestamp> jobGraphQueue = new ConcurrentLinkedQueue<>();
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 can leverage the guava cache to handle the cleanup, expiration and concurrent access. Please refer to how we use it in FileExecutionGraphInfoStore. We can maintain a Cache<JobID, ExecutionGraphInfo> serializableExecutionGraphInfos.

Copy link
Contributor

Choose a reason for hiding this comment

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

I address it myself in https://github.com/KarmaGYZ/flink/tree/FLINK_25329_support_memory_store_in_session . You can take a look and fix the test issue.

* Base test case of execution graph store for {@link FileExecutionGraphInfoStore} and {@link
* MemoryExecutionGraphInfoStore}.
*/
public abstract class ExecutionGraphInfoStoreTest extends TestLogger {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can make it a utility class.

@FangYongs
Copy link
Contributor Author

Thanks @KarmaGYZ , use cache in MemoryExecutionGraphInfoStore instead of queue and hashmap sounds good to me. I have update the code in MemoryExecutionGraphInfoStore and the test case, thanks

Copy link
Contributor

@KarmaGYZ KarmaGYZ 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. The PR is now LGTM. Please address the left minor comments and squash the commits. I'll merge it once CI passed.


@Override
public int size() {
return serializableExecutionGraphInfos.size();
return (int) serializableExecutionGraphInfos.size();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return (int) serializableExecutionGraphInfos.size();
return Math.toIntExact(serializableExecutionGraphInfos.size());

* Test utils class for {@link FileExecutionGraphInfoStore} and {@link
* MemoryExecutionGraphInfoStore}.
*/
public class ExecutionGraphInfoStoreTestUtils {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea of extracting the shared utilities for memory and file store tests. I think this change should belong to a separate hotfix commit.

executionGraphInfoStore.get(executionGraphInfo.getJobId()),
Matchers.nullValue());

// check that the persisted file has been deleted
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// check that the persisted file has been deleted
// check that the store is empty


/** Tests that all persisted files are cleaned up after closing the store. */
@Test
public void testCloseCleansUp() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to use try clause here in case there is IOException from Store#put.

@FangYongs FangYongs force-pushed the FLINK_25329_support_memory_store_in_session branch from 72130f1 to 8c7f47b Compare February 8, 2022 08:52
@FangYongs FangYongs force-pushed the FLINK_25329_support_memory_store_in_session branch from 8c7f47b to 8e4a673 Compare February 8, 2022 12:08
@KarmaGYZ KarmaGYZ force-pushed the FLINK_25329_support_memory_store_in_session branch from 8e4a673 to c6b8f50 Compare February 9, 2022 02:16
@KarmaGYZ KarmaGYZ closed this in 7cb00d1 Feb 9, 2022
MrWhiteSike pushed a commit to MrWhiteSike/flink that referenced this pull request Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants