Skip to content

Commit cdc8fc6

Browse files
attilapirosMarcelo Vanzin
authored andcommitted
[SPARK-30235][CORE] Switching off host local disk reading of shuffle blocks in case of useOldFetchProtocol
### What changes were proposed in this pull request? When `spark.shuffle.useOldFetchProtocol` is enabled then switching off the direct disk reading of host-local shuffle blocks and falling back to remote block fetching (and this way avoiding the `GetLocalDirsForExecutors` block transfer message which is introduced from Spark 3.0.0). ### Why are the changes needed? In `[SPARK-27651][Core] Avoid the network when shuffle blocks are fetched from the same host` a new block transfer message is introduced, `GetLocalDirsForExecutors`. This new message could be sent to the external shuffle service and as it is not supported by the previous version of external shuffle service it should be avoided when `spark.shuffle.useOldFetchProtocol` is true. In the migration guide I changed the exception type as `org.apache.spark.network.shuffle.protocol.BlockTransferMessage.Decoder#fromByteBuffer` throws a IllegalArgumentException with the given text and uses the message type which is just a simple number (byte). I have checked and this is true for version 2.4.4 too. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? This specific case (considering one extra boolean to switch off host local disk reading feature) is not tested but existing tests were run. Closes #26869 from attilapiros/SPARK-30235. Authored-by: “attilapiros” <[email protected]> Signed-off-by: Marcelo Vanzin <[email protected]>
1 parent 297f406 commit cdc8fc6

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

core/src/main/scala/org/apache/spark/internal/config/package.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,14 +1095,6 @@ package object config {
10951095
.booleanConf
10961096
.createWithDefault(false)
10971097

1098-
private[spark] val SHUFFLE_HOST_LOCAL_DISK_READING_ENABLED =
1099-
ConfigBuilder("spark.shuffle.readHostLocalDisk.enabled")
1100-
.doc("If enabled, shuffle blocks requested from those block managers which are running on " +
1101-
"the same host are read from the disk directly instead of being fetched as remote blocks " +
1102-
"over the network.")
1103-
.booleanConf
1104-
.createWithDefault(true)
1105-
11061098
private[spark] val STORAGE_LOCAL_DISK_BY_EXECUTORS_CACHE_SIZE =
11071099
ConfigBuilder("spark.storage.localDiskByExecutors.cacheSize")
11081100
.doc("The max number of executors for which the local dirs are stored. This size is " +
@@ -1148,6 +1140,14 @@ package object config {
11481140
.booleanConf
11491141
.createWithDefault(false)
11501142

1143+
private[spark] val SHUFFLE_HOST_LOCAL_DISK_READING_ENABLED =
1144+
ConfigBuilder("spark.shuffle.readHostLocalDisk.enabled")
1145+
.doc(s"If enabled (and `${SHUFFLE_USE_OLD_FETCH_PROTOCOL.key}` is disabled), shuffle " +
1146+
"blocks requested from those block managers which are running on the same host are read " +
1147+
"from the disk directly instead of being fetched as remote blocks over the network.")
1148+
.booleanConf
1149+
.createWithDefault(true)
1150+
11511151
private[spark] val MEMORY_MAP_LIMIT_FOR_TESTS =
11521152
ConfigBuilder("spark.storage.memoryMapLimitForTests")
11531153
.internal()

core/src/main/scala/org/apache/spark/storage/BlockManager.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ private[spark] class BlockManager(
478478
}
479479

480480
hostLocalDirManager =
481-
if (conf.get(config.SHUFFLE_HOST_LOCAL_DISK_READING_ENABLED)) {
481+
if (conf.get(config.SHUFFLE_HOST_LOCAL_DISK_READING_ENABLED) &&
482+
!conf.get(config.SHUFFLE_USE_OLD_FETCH_PROTOCOL)) {
482483
externalBlockStoreClient.map { blockStoreClient =>
483484
new HostLocalDirManager(
484485
futureExecutionContext,

docs/core-migration-guide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ license: |
3636
- Deprecated method `AccumulableInfo.apply` have been removed because creating `AccumulableInfo` is disallowed.
3737

3838
- Event log file will be written as UTF-8 encoding, and Spark History Server will replay event log files as UTF-8 encoding. Previously Spark writes event log file as default charset of driver JVM process, so Spark History Server of Spark 2.x is needed to read the old event log files in case of incompatible encoding.
39+
40+
- A new protocol for fetching shuffle blocks is used. It's recommended that external shuffle services be upgraded when running Spark 3.0 apps. Old external shuffle services can still be used by setting the configuration `spark.shuffle.useOldFetchProtocol` to `true`. Otherwise, Spark may run into errors with messages like `IllegalArgumentException: Unexpected message type: <number>`.

docs/sql-migration-guide.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ license: |
9797

9898
- Since Spark 3.0, when Avro files are written with user provided non-nullable schema, even the catalyst schema is nullable, Spark is still able to write the files. However, Spark will throw runtime NPE if any of the records contains null.
9999

100-
- Since Spark 3.0, we use a new protocol for fetching shuffle blocks, for external shuffle service users, we need to upgrade the server correspondingly. Otherwise, we'll get the error message `UnsupportedOperationException: Unexpected message: FetchShuffleBlocks`. If it is hard to upgrade the shuffle service right now, you can still use the old protocol by setting `spark.shuffle.useOldFetchProtocol` to `true`.
101-
102100
- Since Spark 3.0, a higher-order function `exists` follows the three-valued boolean logic, i.e., if the `predicate` returns any `null`s and no `true` is obtained, then `exists` will return `null` instead of `false`. For example, `exists(array(1, null, 3), x -> x % 2 == 0)` will be `null`. The previous behaviour can be restored by setting `spark.sql.legacy.arrayExistsFollowsThreeValuedLogic` to `false`.
103101

104102
- Since Spark 3.0, if files or subdirectories disappear during recursive directory listing (i.e. they appear in an intermediate listing but then cannot be read or listed during later phases of the recursive directory listing, due to either concurrent file deletions or object store consistency issues) then the listing will fail with an exception unless `spark.sql.files.ignoreMissingFiles` is `true` (default `false`). In previous versions, these missing files or subdirectories would be ignored. Note that this change of behavior only applies during initial table file listing (or during `REFRESH TABLE`), not during query execution: the net change is that `spark.sql.files.ignoreMissingFiles` is now obeyed during table file listing / query planning, not only at query execution time.

0 commit comments

Comments
 (0)