-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix][broker] Remove failed OpAddEntry from pendingAddEntries #23817
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertNotEquals; | ||
import static org.testng.Assert.assertNotNull; | ||
import static org.testng.Assert.fail; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.Unpooled; | ||
|
@@ -33,6 +32,7 @@ | |
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.function.Predicate; | ||
import lombok.Cleanup; | ||
import org.apache.bookkeeper.mledger.AsyncCallbacks; | ||
|
@@ -59,8 +59,8 @@ | |
import org.testng.annotations.Test; | ||
|
||
@Test(groups = "broker") | ||
public class MangedLedgerInterceptorImplTest extends MockedBookKeeperTestCase { | ||
private static final Logger log = LoggerFactory.getLogger(MangedLedgerInterceptorImplTest.class); | ||
public class ManagedLedgerInterceptorImplTest extends MockedBookKeeperTestCase { | ||
private static final Logger log = LoggerFactory.getLogger(ManagedLedgerInterceptorImplTest.class); | ||
|
||
public static class TestPayloadProcessor implements ManagedLedgerPayloadProcessor { | ||
@Override | ||
|
@@ -446,26 +446,33 @@ public Processor inputProcessor() { | |
return new Processor() { | ||
@Override | ||
public ByteBuf process(Object contextObj, ByteBuf inputPayload) { | ||
throw new RuntimeException(failureMsg); | ||
Commands.skipBrokerEntryMetadataIfExist(inputPayload); | ||
if (inputPayload.readBoolean()) { | ||
throw new RuntimeException(failureMsg); | ||
} | ||
return inputPayload; | ||
} | ||
|
||
@Override | ||
public void release(ByteBuf processedPayload) { | ||
// no-op | ||
fail("the release method can't be reached"); | ||
} | ||
}; | ||
} | ||
}))); | ||
|
||
var ledger = factory.open("testManagedLedgerPayloadProcessorFailure", config); | ||
var countDownLatch = new CountDownLatch(1); | ||
int count = 10; | ||
var countDownLatch = new CountDownLatch(count); | ||
var successCount = new AtomicInteger(0); | ||
var expectedException = new ArrayList<Exception>(); | ||
ledger.asyncAddEntry("test".getBytes(), 1, 1, new AsyncCallbacks.AddEntryCallback() { | ||
|
||
var addEntryCallback = new AsyncCallbacks.AddEntryCallback() { | ||
@Override | ||
public void addComplete(Position position, ByteBuf entryData, Object ctx) { | ||
entryData.release(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the original test, calling
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, sorry, we don't need to release the ByteBuf here. I'll fix the test. Thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
countDownLatch.countDown(); | ||
successCount.incrementAndGet(); | ||
} | ||
|
||
@Override | ||
|
@@ -474,10 +481,23 @@ public void addFailed(ManagedLedgerException exception, Object ctx) { | |
expectedException.add(exception); | ||
countDownLatch.countDown(); | ||
} | ||
}, null); | ||
}; | ||
|
||
for (int i = 0; i < count; i++) { | ||
if (i % 2 == 0) { | ||
ledger.asyncAddEntry(Unpooled.buffer().writeBoolean(true), addEntryCallback, null); | ||
} else { | ||
ledger.asyncAddEntry(Unpooled.buffer().writeBoolean(false), addEntryCallback, null); | ||
} | ||
} | ||
|
||
countDownLatch.await(); | ||
assertEquals(expectedException.size(), 1); | ||
assertEquals(expectedException.get(0).getCause().getMessage(), failureMsg); | ||
assertEquals(expectedException.size(), count / 2); | ||
assertEquals(successCount.get(), count / 2); | ||
for (Exception e : expectedException) { | ||
assertEquals(e.getCause().getMessage(), failureMsg); | ||
} | ||
ledger.close(); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In branch-3.0 & branch-3.3, the test fails due to this line. Removing it makes the test pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaoran10 I'll remove this line while backporting to branch-3.0 and branch-3.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks.