Skip to content

Commit 642b246

Browse files
liyezhang556520andrewor14
authored andcommitted
[SPARK-3941][CORE] _remainingmem should not increase twice when updateBlockInfo
In BlockManagermasterActor, _remainingMem would increase memSize for twice when updateBlockInfo if new storageLevel is invalid and old storageLevel is "useMemory". Also, _remainingMem should increase with original memory size instead of new memSize. Author: Zhang, Liye <[email protected]> Closes #2792 from liyezhang556520/spark-3941-remainMem and squashes the following commits: 3d487cc [Zhang, Liye] make the code concise 0380a32 [Zhang, Liye] [SPARK-3941][CORE] _remainingmem should not increase twice when updateBlockInfo
1 parent be2ec4a commit 642b246

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,16 +457,18 @@ private[spark] class BlockManagerInfo(
457457

458458
if (_blocks.containsKey(blockId)) {
459459
// The block exists on the slave already.
460-
val originalLevel: StorageLevel = _blocks.get(blockId).storageLevel
460+
val blockStatus: BlockStatus = _blocks.get(blockId)
461+
val originalLevel: StorageLevel = blockStatus.storageLevel
462+
val originalMemSize: Long = blockStatus.memSize
461463

462464
if (originalLevel.useMemory) {
463-
_remainingMem += memSize
465+
_remainingMem += originalMemSize
464466
}
465467
}
466468

467469
if (storageLevel.isValid) {
468470
/* isValid means it is either stored in-memory, on-disk or on-Tachyon.
469-
* But the memSize here indicates the data size in or dropped from memory,
471+
* The memSize here indicates the data size in or dropped from memory,
470472
* tachyonSize here indicates the data size in or dropped from Tachyon,
471473
* and the diskSize here indicates the data size in or dropped to disk.
472474
* They can be both larger than 0, when a block is dropped from memory to disk.
@@ -493,7 +495,6 @@ private[spark] class BlockManagerInfo(
493495
val blockStatus: BlockStatus = _blocks.get(blockId)
494496
_blocks.remove(blockId)
495497
if (blockStatus.storageLevel.useMemory) {
496-
_remainingMem += blockStatus.memSize
497498
logInfo("Removed %s on %s in memory (size: %s, free: %s)".format(
498499
blockId, blockManagerId.hostPort, Utils.bytesToString(blockStatus.memSize),
499500
Utils.bytesToString(_remainingMem)))

0 commit comments

Comments
 (0)