Skip to content

Buffer truncated in producer when sending  #1201

Closed

Description

@merlimat

Actual behavior

There is a condition in which the Java producer gets stuck sending truncated buffers. This can be seen happening in very precise conditions:

  • Batching enabled (doesn't reproduce without batching at all)
  • Network used ~100% in brokers/clients
  • A decent number of partitions (eg: 300)
  • Producer reconnecting (not necessarily creating TCP connection, but re-establishing the producer after a bundle unload).

Examples of exceptions :

In consumer logs:

2018-02-07 02:15:48,377 WARN  org.apache.pulsar.client.impl.ClientCnx:159 [pulsar-client-io-1-1] [exceptionCaught] [/100.85.173.79:6650] Got exception IndexOutOfBoundsException : writerIndex: 1751739039 (expected: readerIndex(52) <= writerIndex <= capacity(20896))
java.lang.IndexOutOfBoundsException: writerIndex: 1751739039 (expected: readerIndex(52) <= writerIndex <= capacity(20896))
    at org.apache.pulsar.shade.io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:118)
    at org.apache.pulsar.shade.org.apache.pulsar.common.api.Commands.deSerializeSingleMessageInBatch(Commands.java:819)
    at org.apache.pulsar.client.impl.ConsumerImpl.receiveIndividualMessagesFromBatch(ConsumerImpl.java:904)
    at org.apache.pulsar.client.impl.ConsumerImpl.messageReceived(ConsumerImpl.java:812)
    at org.apache.pulsar.client.impl.ClientCnx.handleMessage(ClientCnx.java:224)
    at org.apache.pulsar.shade.org.apache.pulsar.common.api.PulsarDecoder.channelRead(PulsarDecoder.java:160)

In this case the consumer received a batch where the count of messages was 3, but there were actually only 2 messages in the frame.

In broker logs:

2018-02-08 04:53:44,176 - ERROR [pulsar-io-55-5:Producer@180] - [PersistentTopic{topic=persistent://matteo/local/ns2/t300-partition-270}] [local-1-5055] Failed to verify checksum
2018-02-08 04:53:44,176 - WARN  [pulsar-io-55-5:ServerCnx@177] - [/10.0.0.218:35556] Got exception IndexOutOfBoundsException : readerIndex(0) + length(4) exceeds writerIndex(0): PooledSlicedByteBuf(
ridx: 0, widx: 0, cap: 0/0, unwrapped: PooledUnsafeDirectByteBuf(ridx: 128064, widx: 208394, cap: 262144))
java.lang.IndexOutOfBoundsException: readerIndex(0) + length(4) exceeds writerIndex(0): PooledSlicedByteBuf(ridx: 0, widx: 0, cap: 0/0, unwrapped: PooledUnsafeDirectByteBuf(ridx: 128064, widx: 20839
4, cap: 262144))
        at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1403)
        at io.netty.buffer.AbstractByteBuf.readInt(AbstractByteBuf.java:786)
        at io.netty.buffer.AbstractByteBuf.readUnsignedInt(AbstractByteBuf.java:802)
        at org.apache.pulsar.common.api.PulsarDecoder.channelRead(PulsarDecoder.java:75)

Possible causes

The tcpdump captures show that the "send" request from producer are truncated

Activity

  1. added
    type/bug
    on Feb 8, 2018
  2. added this to the 1.22.0-incubating milestone on Feb 8, 2018
  3. self-assigned this
    on Feb 9, 2018
  4. merlimat commented on Feb 9, 2018

    @merlimat
    ContributorAuthor

    Fixed in #1203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type/bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions