Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Status

...

Page properties


Discussion thread

...

...

...

JIRAhere (<- link to https://issues.apache.org/jira/browse/FLINK-XXXX)

...

thread/c44pbzbl4c5qscmqj8k8m3h3123mggkp
Vote thread
JIRA

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyFLINK-14474

Release1.11


Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

FLIP-36 proposes a new programming paradigm where jobs are built incrementally by the user.

To support this in an efficient manner the partition life-cycle should be extended to support the notion of global cluster partitions, which are partitions that can exist beyond the life-time of a job.

...

Note that this FLIP does not concern itself with the usage of global cluster partitions, including client-side APIs, job-submission, scheduling and reading said partitions.

Terminology/Abbreviations

"Cluster datasets" denote collections of cluster partitions belonging to the same IntermediateDataSet.

"Cluster Global partitions" denote partitions that exist beyond the lifetime of a job.

"Local Job partitions" denote partitions that only exist within the lifetime of a job.

"Promotion" denotes the process of marking a local job partition as globala cluster partition.

"TE": TaskExecutor

"RM": ResourceManager

"JM": JobMaster

Public Interfaces

The REST API shall be extended to provide a listing of existing global cluster partitions, and expose functionality for retrieving or deleting such a partition.

...

This is in contrast to the majority of the internal partition lifecycle life-cycle management, which operates on ResultPartitionIDs,
the reasoning being that there is likely no use-case for partially deleting/reading results, as this would be inherently difficult to model in our APIs (which usually hide the concept of sub-tasks).

METHODURLResponseResponse Code
GET/
partitions
datasets
{ "
partitions
datasets": [
    { "id": "12345ABC",
      "
job-name
jobName": "ProducingJob",
      "
job-id
jobId": "123",
      "
created-at
createdAt": "2018-08-03",
      "isComplete": "true" }]}
200 OK
GET/
partitions
datasets/:
partitionid
datasetid
{ "partitions": [
    { "id": "12345ABC",
      "
job-name
jobName": "ProducingJob",
      "
job-id
jobId": "123",
      "
created-at
createdAt": "2018-08-03",
"descriptors": [
<Based64 encoded byte array> ]}]}
200 OK
DELETE/
partitions
datasets/:
partitionid
datasetid
{ "request-id": "54321CBA" }
202 ACCEPTED
GET/
partitions
datasets/delete-requests/:request-id
{ "status":
    { "id": "IN_PROGRESS"/"COMPLETED" }}
200 OK

Proposed Changes

On a high level, the partition life-cycle must be modified so that

  1. TMs TEs retain global cluster partitions for successful jobsJobMasters hand
  2. the tracking information for global partitions to the ResourceManagerTEs inform the ResourceManager about available cluster partitions via heartbeats
  3. the REST API needs to be extended to allow interactions with the ResourceManager

All changes are only relevant for cases where jobs finish successfully.

Details:

JobMaster

Currently, at job termination, the JM iterates over all connected TEs and calls PartitionTracker#stopTrackingAndReleasePartitionsFor, causing the tracker to remove all partitions hosted on that TE and issue a release call to said TE (and shuffle service).

This behavior must be modified so that, if a job finishes successfully, cluster partitions are not released but promoted. This logic is encapsulated in the PartitionTracker.

The PartitionTracker must be extended to be able to distinguish between successful/failed(,canceled) jobs, so that it can make the appropriate release call to the TE.

The PartitionTracker  interface shall be extended by an additional method for the express purpose of handling the case of a successful job, which will be called from JobMaster#jobStatusChanged :

/**
* Releases all job partitions and promotes all cluster partitions for the given task executor ID, and stops the tracking of partitions that were released/promoted.
*/
void stopTrackingAndReleaseOrPromotePartitionsFor(ResourceID producingTaskExecutorId)

stopTrackingAndReleaseOrPromotePartitionsFor issues the release/promote call to the TE.

TaskExecutor

Currently, on job termination the JM sends a releasePartitions RPC call to all TEs, releasing all blocking partitions they have stored for the respective job.

This RPC call must be extended to additionally pass a set of partitions to promote.

void
releasePartitions
releaseOrPromotePartitions(JobID jobId, Collection<ResultPartitionID> partitionsToRelease, Collection<ResultPartitionID> partitionsToPromote)

The set of partitions to release may contain local and/or global partitions; the promotion set must sets may only refer to local job partitions. This effectively means that the JM cannot issue release calls for cluster partitions.

While it is technically feasible to do this as 2 RPC calls (one for releasing partitions that shouldn't be promoted, another RPC for promoting the remaining ones) this would potentially double the number of RPC invocations at the end of job.
This can be especially problematic given the possibility of many short lived jobs being executed in rapid succession.

The decision on whether to release or promote a partition can not be deferred to the TE, as it would not able to make the correct choice in case of a job restart, where all partitions should be released.

To store these partitions we can generalize the PartitionTable in the TE to PartitionTable<AbstractID> and store global partitions under the ResourceManagerId of the RM.introduce another Set<ResultPartitionID> into the TE or PartitionTable.


The RM is regularly informed about promoted partitions, piggybacking on the heartbeats that are already being exchanged between the two. This makes it easy to keep the state of the RM and TE in sync.


Cluster Global partitions will be cleaned up in in these 3 cases:

  1. The TaskExecutor shuts down for whatever reason.
  2. An explicit release call was issued via RPC from the RM.
  3. A heartbeat to the RM times out. This is because the RM could've issued release calls for partitions which may have been lost.

An alternative for case 3) would be to acknowledge the release of partitions, and track on the RM which delete requests have been fully processed. This is a more complex solution however, and could also be added as a follow-up.

JobMaster

The release logic on the JM that is executed on job termination must be adjusted accordingly. At job termination, the JM iterates over all connected TEs and calls PartitionTracker#stopTrackingAndReleasePartitionsFor, causing the tracker to remove all partitions hosted on that TE and issue a release call to said TE (and shuffle service).

The PartitionTracker must be extended to be able to distinguish between successful/failed(,canceled) jobs, so that it can make the appropriate release call to the TE. Fortunately there is only a single case where this is relevant: If the job finishes.

The PartitionTracker  interface shall be extended by additional methods for the express purpose of handling the case of a successful job, which will be called from JobMaster#jobStatusChanged :

...

/**
* Releases all non-persistent partitions and promotes all persistent partitions for the given task executor ID, and stops the tracking of partitions that were released/promoted.
*/
void stopTrackingAndReleaseOrPromotePartitionsFor(ResourceID producingTaskExecutorId)

For case 2) a new RPC method is required, which will be exclusively used by the RM.

void releaseClusterPartitions(Collection<ResultPartitionID> partitionsToRelease)

ResourceManager

The RM is informed about cluster partitions via heartbeats from TEs.

stopTrackingAndReleaseOrPromotePartitionsFor issues the release/promote call to the TE, while getPersistedBlockingPartitions is required for a safe hand-off of the partition location data from JM to RM.

It must be ensured that at all times during the hand-off either the JM or RM is capable of cleaning up partitions on the TE should an error occur.

For example, releasing&promoting partitions on the TE must not be done before partitions were handed to the RM; if the JM crashes after the promotion but before the hand-off to the RM, the TE would neither release partitions due to the loss of the JM, nor would the RM ever issue release calls. This is problematic since the RM relies on the TE to determine whether it still hosts partitions (TaskExecutor#canBeReleased); with some partitions never being released the cluster could never shut down. One could set things up so that the RM takes over this responsibility in the context of global partitions, but it would introduce a weird inconsistency, where for local partitions we care about the actual state on the TE, but for global partitions about the supposed state stored on the RM.

As such we must first retrieve the set of to-be-promoted partitions from the tracker, pass them to the RM and afterwards issue the release/promote call. This does imply that there is a window where the partition state is not in sync within the cluster: The TE still treats all partitions as local, whereas to the RM the TE is already hosting global partitions. This shouldn't be a problem, so long as a DELETE call for a global partition is executed correctly on the TE regardless of whether the partition is global or not according to the local state.

Since the job has already terminated we do not have to worry that the partition set changes between calls.

ResourceManager

To support handing over partitions the ResourceManagerGateway must be extended to accept a set of PartitionInfos . (a Tuple2 containing the ResourceID of the producing TE and the ResultPartitionDeploymentDescriptor)

...

The given partitions should be stored in something akin to the PartitionTracker used by the JM; the core requirements are as follows:

  • support fast look-ups for the set of partitions for a given TE (identified by a ResourceID), for easier book-keeping updates in case a TE goes down
  • support fast look-ups for the set of partitions for a given IntermediateResult, to facilitate performant deletions of descriptor look-ups

The To fully support external shuffle services the RM will require access to trimmed down ShuffleMaster-like component to issue release calls and list available partitions. A first version may omit this part, limiting support to the NettyShuffleService.

ShuffleService

For the new shuffle service component (for now called ClusterPartitionShuffleClient) living in the RM we require a new interface and have to extend the ShuffleServiceFactory to create this new component:

ClusterPartitionShuffleClient<SD extends ShuffleDescriptor>:

Collection<SD> getClusterPartitions()

void releasePartitionExternally(SD shuffleDescriptor)

ShuffleServiceFactory:

ClusterPartitionShuffleClient<SD> createClusterPartitionShuffleClient(Configuration configuration)

With these changes there is a slight difference in how Flink interacts with the ShuffleMaster, as certain partitions may never be released on the ShuffleMaster after being registered.

Additionally, in contrast to the ShuffleMaster the new component is not informed pre-emptively about a partition to be released (in contrast to the ShuffleMaster for calling ShuffleMaster#releasePartitionsExternally on release global partitions, on which all partitions are first registered), the implication being that the release of partitions must be possible without relying on local state.

REST API

The extensions to the REST API do not require any changes to the existing REST code, as the WebMonitorEndpoint already contains a retriever for the ResourceManagerGateway.

We only require similar appropriate extensions to the ResourceManagerGateway for retrieving the ResultPartitionDeploymentDescriptors and listing or deleting partitionscluster datasets.

/**
 * Returns the {@link ResultPartitionDeploymentDescriptor} of each partition belonging to the {@link IntermediateResult}, identified by the given {@link IntermediateDatasetID}.
 */
CompletableFuture<Collection<ResultPartitionDeploymentDescriptor>> getResultPartitionDeploymentDescriptors(IntermediateDatasetID intermediateResultId)


/**
 * Release all partitions belonging to the {@link IntermediateResult}, identified by the given {@link IntermediateDatasetID}.
 */
void
CompletableFuture<Void> 
releaseGlobalPartition
releaseClusterPartition(IntermediateDatasetID intermediateResultId)

/**
* Returns all datasets for which partitions are being tracked.
*/
CompletableFuture<Map<IntermediateDataSetID, DataSetMetaInfo>> listDataSets();

Compatibility, Deprecation, and Migration Plan

This is an extension of the existing partition life-cycle and does not impact existing functionality.

Test Plan

Will be tested via unit/IT cases. IT cases can generate job graphs with vertices that create global cluster partitions, which should not be cleaned up on job shutdown. The RM state can be verified through the REST API, whereas for the TE state we will have to resort to checking local storage.

Implementation notes

The core functionality required by FLIP-36 was implemented in FLINK-14474.

Some parts of the FLIP have been deferred to follow-ups:

  • extensive meta-data about producing job / creation dates
  • interactions of the ResourceManager with the ShuffleService
  • retrieval of partition descriptors through the REST API, as this may significantly warp the resource requirements which may render the heartbeat approach unfeasible

Rejected Alternatives

...

Single method for releasing partitions on the JM

Releasing partitions could be facilitated via a single method on the TE, but this needlessly gives the JM/RM more capabilities than required.

Pass partition info from JM to RM instead of via heartbeat from TM to RM

Instead of having the TE inform the RM about hosted partitions via heartbeat messages it would also be possible for the JM to inform the RM about partitions that have been promoted.

This approach requires careful handling of the handoff to ensure that either the JM or RM are at all times in a position to release partitions on the TE in case of errors, which implies interface constraints on the side of the TE since the JM/RM may issue release calls irrespective of whether partitions have been already promoted or not.

Crucially however this approach requires the JM to connect to the RM at the end of the job, which currently is only required at the very start. This makes the JM fairly independent of the RM, which is a nice property.

Persist dataset to external FS

Cluster Global partitions are only truly relevant for jobs that want to re-use partitions from previous jobs. From a pure functionality standpoint, all one really needs to do is persist the dataset to durable storage, like writing it to HDFS, and in subsequent jobs declare a source that reads that partition again.

The downsides to this approach are that an additional medium for persisting data is required (which will require a fair amount of maintenance overhead since these partitions should be relatively short-lived) and added latency due to writing/reading the data. In contrast, global cluster partitions are just written into local storage, and, with tasks potentially being deployed onto the same machine as the partition, the process of reading the data can be as efficient as reading from any blocking partition on the same machine. Additionally, API's can trigger the cleanup of partitions through the REST API, thus not requiring any additional dependencies or permissions.