Skip to content

Commit

Permalink
[apache#1571] fix(server): Memory may leak when EventInvalidException…
Browse files Browse the repository at this point in the history
… occurs
  • Loading branch information
leslizhang committed Mar 15, 2024
1 parent 7d6c01c commit 1786106
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ public void shuffleIdToSizeTest() {
@Test
public void cacheShuffleDataTest() {
String appId = "cacheShuffleDataTest";
int shuffleId = 1;
shuffleBufferManager.setShuffleTaskManager(mockShuffleTaskManager);
ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
when(mockShuffleTaskManager.getAppReadLock(appId)).thenReturn(rwLock.readLock());
when(mockShuffleServer.getShuffleTaskManager()).thenReturn(mockShuffleTaskManager);
int startPartitionNum = (int) ShuffleServerMetrics.gaugeTotalPartitionNum.get();
int shuffleId = 1;
StatusCode sc =
shuffleBufferManager.cacheShuffleData(appId, shuffleId, false, createData(0, 16));
assertEquals(StatusCode.NO_REGISTER, sc);
Expand Down Expand Up @@ -339,11 +339,11 @@ public void cacheShuffleDataTest() {
@Test
public void cacheShuffleDataWithPreAllocationTest() {
String appId = "cacheShuffleDataWithPreAllocationTest";
int shuffleId = 1;
shuffleBufferManager.setShuffleTaskManager(mockShuffleTaskManager);
ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
when(mockShuffleTaskManager.getAppReadLock(appId)).thenReturn(rwLock.readLock());
when(mockShuffleServer.getShuffleTaskManager()).thenReturn(mockShuffleTaskManager);
int shuffleId = 1;
shuffleBufferManager.registerBuffer(appId, shuffleId, 0, 1);
// pre allocate memory
shuffleBufferManager.requireMemory(48, true);
Expand Down Expand Up @@ -413,11 +413,11 @@ public void bufferSizeTest() throws Exception {
when(mockShuffleServer.getShuffleTaskManager()).thenReturn(mock(ShuffleTaskManager.class));

String appId = "bufferSizeTest";
int shuffleId = 1;
when(mockShuffleServer.getShuffleTaskManager()).thenReturn(mockShuffleTaskManager);
shuffleBufferManager.setShuffleTaskManager(mockShuffleTaskManager);
ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
when(mockShuffleTaskManager.getAppReadLock(appId)).thenReturn(rwLock.readLock());
int shuffleId = 1;
when(mockShuffleServer.getShuffleTaskManager()).thenReturn(mockShuffleTaskManager);
shuffleBufferManager.registerBuffer(appId, shuffleId, 0, 1);
shuffleBufferManager.registerBuffer(appId, shuffleId, 2, 3);
Expand Down Expand Up @@ -547,11 +547,11 @@ public void flushSingleBufferTest(@TempDir File tmpDir) throws Exception {
when(mockShuffleServer.getShuffleTaskManager()).thenReturn(mock(ShuffleTaskManager.class));

String appId = "bufferSizeTest";
int shuffleId = 1;
shuffleBufferManager.setShuffleTaskManager(mockShuffleTaskManager);
ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
when(mockShuffleTaskManager.getAppReadLock(appId)).thenReturn(rwLock.readLock());
when(mockShuffleServer.getShuffleTaskManager()).thenReturn(mockShuffleTaskManager);
int shuffleId = 1;
shuffleBufferManager.registerBuffer(appId, shuffleId, 0, 1);
shuffleBufferManager.registerBuffer(appId, shuffleId, 2, 3);
shuffleBufferManager.cacheShuffleData(appId, shuffleId, false, createData(0, 64));
Expand Down Expand Up @@ -707,11 +707,11 @@ public void flushBufferTestWhenNotSelectedStorage(@TempDir File tmpDir) throws E
when(mockShuffleServer.getShuffleTaskManager()).thenReturn(mock(ShuffleTaskManager.class));

String appId = "bufferSizeTest";
int shuffleId = 1;
shuffleBufferManager.setShuffleTaskManager(mockShuffleTaskManager);
ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
when(mockShuffleTaskManager.getAppReadLock(appId)).thenReturn(rwLock.readLock());
when(mockShuffleServer.getShuffleTaskManager()).thenReturn(mockShuffleTaskManager);
int shuffleId = 1;
shuffleBufferManager.registerBuffer(appId, shuffleId, 0, 1);
shuffleBufferManager.registerBuffer(appId, shuffleId, 2, 3);
shuffleBufferManager.cacheShuffleData(appId, shuffleId, false, createData(0, 64));
Expand Down

0 comments on commit 1786106

Please sign in to comment.