Skip to content

Conversation

@JingsongLi
Copy link
Contributor

What is the purpose of the change & Brief change log

Introduce Compaction operators:

The compaction operator graph is:
TempFileWriter|parallel ---(InputFile&EndInputFile)---> CompactCoordinator|non-parallel
---(CompactionUnit&EndCompaction)--->CompactOperator|parallel---(PartitionCommitInfo)--->
PartitionCommitter|non-parallel

Because the end message is a kind of barrier of record messages, they can only be transmitted
in the way of full broadcast in the link from coordinator to compact operator.

Introduce CompactCoordinator

This is the single (non-parallel) monitoring task which coordinate input files to compaction units.

  • Receives in-flight input files inside checkpoint.
  • Receives all upstream end input messages after the checkpoint completes successfully,
    starts coordination.

NOTE: The coordination is a stable algorithm, which can ensure that the downstream can
perform compaction at any time without worrying about fail over.

STATE: This operator stores input files in state, after the checkpoint completes successfully,
input files are taken out from the state for coordination.

Introduce CompactOperator

Receives compaction units to do compaction. Send partition commit information after
compaction finished.

Use BulkFormat to read and use BucketWriter to write.

STATE: This operator stores expired files in state, after the checkpoint completes successfully,
We can ensure that these files will not be used again and they can be deleted from the
file system.

Verifying this change

  • CompactOperatorsTest
  • BinPackingTest

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, Kubernetes/Yarn/Mesos, ZooKeeper: no
  • The S3 file system connector: no

Documentation

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

@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 73d3642 (Thu Oct 22 09:13:15 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 Oct 22, 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

/**
* A partitioned input file.
*/
public static class InputFile implements CoordinatorInput {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing serialVersionUID

/**
* A flag to end file input.
*/
public static class EndInputFile implements CoordinatorInput {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing serialVersionUID

.toArray(String[]::new);
}

public boolean isTaskMessage(int taskId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

 * {@link CompactionUnit} and {@link EndCompaction} must be sent to the downstream in an orderly
 * manner, while {@link EndCompaction} is broadcast emitting, so unit and endCompaction use the
 * broadcast emitting mechanism together. Since unit is broadcast, we want it to be processed by
 * a single task, so we carry the ID in the unit and let the downstream task select its own unit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, there is a bug here, should be:

public boolean isTaskMessage(int taskNumber, int taskId) {
    return unitId % taskNumber == taskId;
}

if (triggerCommit) {
commitUpToCheckpoint(endInputFile.getCheckpointId());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Throw an exception for unknown elements?

}

/**
* A flag to end file input.
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems more of a flag to end checkpoint rather than file input?

}

@Override
public void notifyCheckpointComplete(long checkpointId) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

If something goes wrong in this method and the job fails over, will this method be called again for the same checkpointId?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, then will wait for next checkpoint notify.


Assert.assertEquals(7, outputs.size());

assertUnit(outputs.get(0), 0, "p0", Arrays.asList("f0", "f1", "f4"));
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 CompactCoordinator doesn't guarantee to generate CompactionUnit in any specific order of partitions, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean the order of partitions? There is no relationship between partitions, so there is no need to guarantee this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah... but then how could we assert the first output is for p0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean we should sort it before assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll do it


// check all compacted file generated
Assert.assertTrue(fs.exists(new Path(folder, "compacted-f0")));
Assert.assertTrue(fs.exists(new Path(folder, "compacted-f2")));
Copy link
Contributor

Choose a reason for hiding this comment

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

Also verify f3 and f6 are not compacted at this point.

Copy link
Contributor

@lirui-apache lirui-apache left a comment

Choose a reason for hiding this comment

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

LGTM

@JingsongLi JingsongLi merged commit 2bbbbc0 into apache:master Oct 29, 2020
@JingsongLi JingsongLi deleted the compactOperator branch November 5, 2020 09:38
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