BewareMyPower commented on issue #7479:
URL: https://github.com/apache/pulsar/issues/7479#issuecomment-657690737


   It looks like a problem of broker. I have tested following Java client 
(commit  c94067d) with broker 2.6.0 standalone:
    
   ```java
   import org.apache.pulsar.client.api.*;
   
   import java.util.Arrays;
   import java.util.concurrent.TimeUnit;
   
   public class ProducerDemo {
       public static void main(String[] args) {
           try (PulsarClient client = 
PulsarClient.builder().serviceUrl("pulsar://localhost:6650").build()) {
               Consumer<String> consumer = client.newConsumer(Schema.STRING) //
                       .topic("ParTopic") //
                       .subscriptionName("my-sub") //
                       .subscriptionType(SubscriptionType.Key_Shared) //
                       .subscribe();
               Producer<String> producer = client.newProducer(Schema.STRING) //
                       .compressionType(CompressionType.LZ4) //
                       .topic("ParTopic") //
                       .create();
               MessageId id = producer.newMessage().value("hello world").send();
               System.out.println("send to " + 
Arrays.toString(id.toByteArray()));
               producer.close();
               Message<String> msg = consumer.receive(30, TimeUnit.SECONDS);
               System.out.println("receive " + new String(msg.getData()));
               consumer.close();
           } catch (PulsarClientException e) {
               e.printStackTrace();
           }
       }
   }
   ```
   
   It stuck at `consumer.receive` until timeout exceeds. The broker's log is
   
   ```
   01:23:14.206 [bookkeeper-ml-workers-OrderedExecutor-2-0] ERROR 
org.apache.bookkeeper.common.util.SafeRunnable - Unexpected throwable caught 
   java.lang.IndexOutOfBoundsException: readerIndex: 77, writerIndex: 
-268173235 (expected: 0 <= readerIndex <= writerIndex <= capacity(4096))
        at 
io.netty.buffer.AbstractByteBuf.checkIndexBounds(AbstractByteBuf.java:112) 
~[io.netty-netty-buffer-4.1.48.Final.jar:4.1.48.Final]
        at 
io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:135) 
~[io.netty-netty-buffer-4.1.48.Final.jar:4.1.48.Final]
        at 
org.apache.pulsar.common.protocol.Commands.deSerializeSingleMessageInBatch(Commands.java:1707)
 ~[org.apache.pulsar-pulsar-common-2.6.0.jar:2.6.0]
        at 
org.apache.pulsar.broker.service.AbstractBaseDispatcher.peekStickyKey(AbstractBaseDispatcher.java:161)
 ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
        at 
org.apache.pulsar.broker.service.persistent.PersistentStickyKeyDispatcherMultipleConsumers.sendMessagesToConsumers(PersistentStickyKeyDispatcherMultipleConsumers.java:145)
 ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
        at 
org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers.readEntriesComplete(PersistentDispatcherMultipleConsumers.java:476)
 ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
        at 
org.apache.bookkeeper.mledger.impl.OpReadEntry.lambda$checkReadCompletion$2(OpReadEntry.java:152)
 ~[org.apache.pulsar-managed-ledger-2.6.0.jar:2.6.0]
        at 
org.apache.bookkeeper.mledger.util.SafeRun$1.safeRun(SafeRun.java:32) 
~[org.apache.pulsar-managed-ledger-2.6.0.jar:2.6.0]
        at 
org.apache.bookkeeper.common.util.SafeRunnable.run(SafeRunnable.java:36) 
[org.apache.bookkeeper-bookkeeper-common-4.10.0.jar:4.10.0]
        at 
org.apache.bookkeeper.common.util.OrderedExecutor$TimedRunnable.run(OrderedExecutor.java:203)
 [org.apache.bookkeeper-bookkeeper-common-4.10.0.jar:4.10.0]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[?:1.8.0_251]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[?:1.8.0_251]
        at 
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
 [io.netty-netty-common-4.1.48.Final.jar:4.1.48.Final]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_251]
   ```
   
   The worse thing is that this corrupted message (I guess) could affect 
following messages. After that, I changed `LZ4` to `NONE`, it still didn't 
work. But if I stopped the standalone, then delete `data` directory, and 
started the standalone again, `Key_Shared` with `Compression.NONE` worked.
   
   I didn't test with latest broker, did the latest broker solve this problem 
or just change some behaviour? @sijie 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to