Skip to content

[#825][part-5] feat(spark): Adds the RPC interface to reassign the ShuffleServer list. - #1146

Merged
leixm merged 1 commit into
apache:masterfrom
yl09099:uniffle-825-5
Nov 3, 2023
Merged

[#825][part-5] feat(spark): Adds the RPC interface to reassign the ShuffleServer list.#1146
leixm merged 1 commit into
apache:masterfrom
yl09099:uniffle-825-5

Conversation

@yl09099

@yl09099 yl09099 commented Aug 14, 2023

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Adds the RPC interface to reassign the ShuffleServer list.

Ⅰ. Overall objective:

  1. During the shuffle write phase, the ShuffleServer reports faulty nodes and reallocates the ShuffleServer list;
  2. Triggers a Stage level retry of SPARK. The shuffleServer node is excluded and reallocated before the retry.

Ⅱ. Implementation logic diagram:

image

Ⅲ. As shown in the picture above:

  1. During Shuffle registration, obtain the ShuffleServer list to be written through the RPC interface of a Coordinator Client by following the solid blue line step. The list is bound using ShuffleID.
    2, the Task of Stage starts, solid steps, in accordance with the green by ShuffleManager Client RPC interface gets to be written for shuffleIdToShuffleHandleInfo ShuffleServer list;
  2. In the Stage, if Task fails to write blocks to the ShuffleServer, press the steps in red to report ShuffleServer to FailedShuffleServerList in RSSShuffleManager through the RPC interface.
  3. FailedShuffleServerList records the number of ShuffleServer failures. After the number of failures reaches the maximum number of retries of the Task level, follow the steps in dotted orange lines. Through the RPC interface of a Coordinator Client, obtain the list of ShuffleServer files to be written (the ShuffleServer files that fail to be written are excluded). After obtaining the list, go to Step 5 of the dotted orange line. Throwing a FetchFailed Exception triggers a stage-level retry for SPARK;
  4. Attempt 1 is generated by the SPARK Stage level again. Pull the corresponding ShuffleServer list according to the green dotted line.

Why are the changes needed?

Fix: #825

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing UT.

@yl09099 yl09099 changed the title [#825][part-4] feat(spark): Adds the RPC interface to reassign the ShuffleServer list [#825][part-5] feat(spark): Adds the RPC interface to reassign the ShuffleServer list Aug 14, 2023
@codecov-commenter

codecov-commenter commented Aug 14, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1146 (f26a569) into master (5a89609) will increase coverage by 0.86%.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##             master    #1146      +/-   ##
============================================
+ Coverage     53.74%   54.61%   +0.86%     
+ Complexity     2691     2679      -12     
============================================
  Files           401      383      -18     
  Lines         23406    21084    -2322     
  Branches       1992     1992              
============================================
- Hits          12580    11515    -1065     
+ Misses        10051     8868    -1183     
+ Partials        775      701      -74     
Files Coverage Δ
...fle/client/impl/grpc/ShuffleManagerGrpcClient.java 26.31% <0.00%> (-3.10%) ⬇️
...fle/client/response/RssReassignServersReponse.java 0.00% <0.00%> (ø)
...ffle/client/request/RssReassignServersRequest.java 0.00% <0.00%> (ø)
...fle/shuffle/manager/ShuffleManagerGrpcService.java 31.01% <0.00%> (-2.15%) ⬇️

... and 23 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@yl09099 yl09099 closed this Oct 10, 2023
@yl09099 yl09099 reopened this Oct 10, 2023
@yl09099 yl09099 changed the title [#825][part-5] feat(spark): Adds the RPC interface to reassign the ShuffleServer list [#825][part-5] feat(spark): Adds the RPC interface to reassign the ShuffleServer list. Oct 31, 2023
@yl09099

yl09099 commented Oct 31, 2023

Copy link
Copy Markdown
Contributor Author

@jerqi @leixm Please look at it for me.

*/
void addFailuresShuffleServerInfos(String shuffleServerId);

boolean reShuffleAssignments(int stageId, int stageAttemptNumber, int shuffleId, int numMaps);

@roryqi roryqi Oct 31, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reShuffleAssignments -> reassignShuffleServers ?

}

@Override
public void reallocationShuffleServers(

@roryqi roryqi Oct 31, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reallocationShuffleServers -> reassignShuffleServers?

* If the shuffleServer is reassigned, we need to clear the metadata of the completed Task,
* otherwise some of the Stage's data will be lost
*/
if (reallocationFlag) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reallocation -> needReassign ?

public void addFailuresShuffleServerInfos(String shuffleServerId) {}

@Override
public boolean reShuffleAssignments(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reShuffleAssignments -> reassignShuffleServers

* @param numPartitions
*/
@Override
public synchronized boolean reShuffleAssignments(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto.

* Prevent multiple tasks from reporting FetchFailed, resulting in multiple ShuffleServer
* assignments, stageID, Attemptnumber Whether to reallocate the combination flag;
*/
private Map<String, Boolean> stageAttemptTag;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we give this variable a better name?

@roryqi
roryqi requested a review from leixm October 31, 2023 11:03
@roryqi

roryqi commented Oct 31, 2023

Copy link
Copy Markdown
Contributor

@leixm Could you help me review this pr?

@yl09099
yl09099 force-pushed the uniffle-825-5 branch 5 times, most recently from 5883c28 to 78b115e Compare November 1, 2023 02:33
* Prevent multiple tasks from reporting FetchFailed, resulting in multiple ShuffleServer
* assignments, stageID, Attemptnumber Whether to reallocate the combination flag;
*/
private Map<String, Boolean> preventDoubleAllocationFlag = JavaUtils.newConcurrentMap();

@roryqi roryqi Nov 1, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

serversAssignments?

public synchronized boolean reassignShuffleServers(
int stageId, int stageAttemptNumber, int shuffleId, int numPartitions) {
String stageIdAndAttempt = stageId + "_" + stageAttemptNumber;
Boolean reassignFlag =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reassignFlag -> needReassgin

* Prevent multiple tasks from reporting FetchFailed, resulting in multiple ShuffleServer
* assignments, stageID, Attemptnumber Whether to reallocate the combination flag;
*/
private Map<String, Boolean> preventDoubleAllocationFlag;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

serverAssignedInfos?

String stageIdAndAttempt = stageId + "_" + stageAttemptNumber;
Boolean reallocationFlag =
preventDoubleAllocationFlag.computeIfAbsent(stageIdAndAttempt, id -> false);
if (!reallocationFlag) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reallocationFlag -> needReassign?


public class RssReassignServersReponse extends ClientResponse {

private boolean reallocationFlag;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rellactionFlag -> needReassign?

Comment thread proto/src/main/proto/Rss.proto Outdated
rpc getPartitionToShufflerServer(PartitionToShuffleServerRequest) returns (PartitionToShuffleServerResponse);
// Report write failures to ShuffleManager
rpc reportShuffleWriteFailure (ReportShuffleWriteFailureRequest) returns (ReportShuffleWriteFailureResponse);
// Reallocate the RPC interface of the ShuffleServer list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reallocate -> Reassign?

}

@Override
public RssReassignServersReponse reallocationShuffleServers(RssReassignServersRequest req) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

realloctionShuffleServers -> reassignShuffleServers?

throw new RssException("registerShuffle failed!", throwable);
}
/**
* we need to clear the metadata of the completed Task, otherwise some of the Stage's data

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

completed Task -> completed tasks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stage -> stage.

@roryqi roryqi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two questions:
If one shuffle server is allocated by two stages, one stage trigger the reassignment, what will it happen?
Do we remove the shuffle server and then won't send the heartbeat after we trigger the reassignment?

Comment thread proto/src/main/proto/Rss.proto Outdated

message ReassignServersReponse{
StatusCode status = 1;
bool reallocationFlag = 2;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

needReassign?

@yl09099
yl09099 force-pushed the uniffle-825-5 branch 2 times, most recently from 633502d to bcf10a1 Compare November 1, 2023 06:07
@yl09099

yl09099 commented Nov 1, 2023

Copy link
Copy Markdown
Contributor Author

Two questions: If one shuffle server is allocated by two stages, one stage trigger the reassignment, what will it happen? Do we remove the shuffle server and then won't send the heartbeat after we trigger the reassignment?

  1. If the same ShuffleServer triggers a retry on the first stage, the task in the second Stage will be sensed once the failure is triggered and the Stage retry will be triggered.
  2. Heartbeat problem resolved.

@roryqi

roryqi commented Nov 2, 2023

Copy link
Copy Markdown
Contributor

LGTM, let @leixm take an another look.

int retryTimes = sparkConf.get(RssSparkConfig.RSS_CLIENT_ASSIGNMENT_RETRY_TIMES);
int estimateTaskConcurrency = RssSparkShuffleUtils.estimateTaskConcurrency(sparkConf);
/** Before reassigning ShuffleServer, clear the ShuffleServer list in ShuffleWriteClient. */
shuffleWriteClient.unregisterShuffle(appId, shuffleId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When cleaning up at this time, some tasks are reading this data. Will this have any impact?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When cleaning up at this time, some tasks are reading this data. Will this have any impact?

Write failures are handled here, and read cases should not be involved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay.

* will be lost
*/
try {
unregisterAllMapOutput(shuffleId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if there are not enough ShuffleServers to assign at this time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What happens if there are not enough ShuffleServers to assign at this time?

The ShuffleServer allocation was done before the metadata was cleaned, and the amount was insufficient to throw an exception directly, a few lines of code before this code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay.

@leixm

leixm commented Nov 3, 2023

Copy link
Copy Markdown
Contributor

LGTM.

@leixm
leixm merged commit adafac4 into apache:master Nov 3, 2023
@leixm

leixm commented Nov 3, 2023

Copy link
Copy Markdown
Contributor

Merged, thanks @jerqi @yl09099

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Umbrella] Dynamic shuffle server assignment

4 participants