GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PIP 107: Introduce the chunk message ID · Issue #12402 · apache/pulsar

PIP 107: Introduce the chunk message ID #12402

New issue
Copy link
New issue
Copy link
Closed
Closed
PIP 107: Introduce the chunk message ID#12402
Copy link
Assignees
RobertIndie
Labels
lifecycle/staletype/PIP

Description

@RobertIndie
RobertIndie
opened on Oct 18, 2021
Issue body actions

Motivation

Currently, when we send chunked messages, the producer returns the message-id of the last chunk. This can cause some problems. For example, when we use this message-id to seek, it will cause the consumer to consume from the position of the last chunk, and the consumer will mistakenly think that the previous chunks are lost and choose to skip the current message. If we use the inclusive seek, the consumer may skip the first message, which brings the wrong behavior.

Here is the simple code used to demonstrate the problem.

var msgId = producer.send(...); // eg. return 0:1:-1

var otherMsg = producer.send(...); // return 0:2:-1

consumer.seek(msgId); // inclusive seek

var receiveMsgId = consumer.receive().getMessageId(); // it may skip the
first message and return like 0:2:-1

Assert.assertEquals(msgId, receiveMsgId); // fail

Earlier, we tried to fix the problem by having the producer and the consumer return the firstChunkMessageID.(Discussion and Draft pull requests). However, this may have some impact on the original business logic. If users rely on the feature of returning lastChunkMessageId, they will be affected. For this reason, we propose a new solution to minimize the impact. In this PIP, the expected impact for the original user will only occur when seeking the chunk message.

Goal

We can solve the above problem by introducing chunk message ID to the producer and consumer. Here are some goals for this PIP:

  • Compatibility: When the Producer and the consumer are processing the chunk Message, the chunk message-id is returned to the user. In order to achieve better compatibility with the original business logic, the chunk message-id need to be consistent with the original behavior.
  • New Feature: The user can get the message-id of the first chunk and the last chunk by the chunk message-id.
  • Fix for consumer.seek: To fix the above problem, the consumer will use firstChunkMessageId if the message-id passed in is a chunk message id when seeking.

API Changes and Implementation

  1. Introduce a new Message ID type: Chunk Message ID. The chunk message id inherits from MessageIdImpl and adds two new methods: getFirstChunkMessageId and getLastChunkMessageID. For other method implementations, the lastChunkMessageID is called directly, which is compatible with much of the existing business logic.

Here is the simple demo codes for the ChunkMessageID:

public class ChunkMessageIdImpl extends MessageIdImpl implements MessageId {
    private final MessageIdImpl firstChunkMsgId;

    public ChunkMessageIdImpl(MessageIdImpl firstChunkMsgId, MessageIdImpl lastChunkMsgId) {
        super(lastChunkMsgId.getLedgerId(), lastChunkMsgId.getEntryId(), lastChunkMsgId.getPartitionIndex());
        this.firstChunkMsgId = firstChunkMsgId;
    }

    public MessageIdImpl getFirstChunkMessageId() {
        return firstChunkMsgId;
    }

    public MessageIdImpl getLastChunkMessageId() {
        return this;
    }
}
  1. The chunk message-id is returned to the user when the Producer produces the chunk message or when the consumer consumes the chunk message.

  2. In cosumer.seek, use the first chunk message-id of the chunk message-id. This will solve the problem caused by seeking chunk messages. This is also the impact of this PIP on the original business logic.

  3. In order to make the chunkMessaegId serializable and deserializable, we need to change the proto definition of MessageIdData. Add the first_chunk_message_id optional field to the MessageIdData in proto file:

message MessageIdData {
    required uint64 ledgerId = 1;
    required uint64 entryId  = 2;
    optional int32 partition = 3 [default = -1];
    optional int32 batch_index = 4 [default = -1];
    repeated int64 ack_set = 5;
    optional int32 batch_size = 6;

    // For the chunk message id, we need to specify the first chunk message id.
    optional MessageIdData first_chunk_message_id = 7;
}
  1. ChunkMessageId.tostirng() will return both firstChunkMessageId and lastChunkMessageId.

Compatibility

For serialization and deserialization of MessageId, it is both forward compatibility and backward compatibility.

The old version of message-id raw data for deserialization, regardless of whether it is a chunk message, will all be serialized into MessageIdImpl in the current client version. In this case, the problem of seeking chunk messages mentioned above will still exist.
Older versions of the client will have no impact when serializing newer versions of chunk message id raw data.

Here is the PR to demonstrate this PIP: #12403.

Activity

  1. RobertIndie
    added
    type/PIP
    on Oct 18, 2021
  2. codelipenghui
    added a commit that references this issue on Dec 29, 2021

    [PIP 107][Client] Introduce chunk message ID (#12403)

    862e120
  3. wuzhanpeng
    added a commit that references this issue on Jan 5, 2022

    [PIP 107][Client] Introduce chunk message ID (apache#12403)

    673d07f
  4. github-actions commented on Feb 27, 2022

    @github-actions
    github-actionsBot
    on Feb 27, 2022
    More actions

    The issue had no activity for 30 days, mark with Stale label.

  5. github-actions
    added
    lifecycle/stale
    on Feb 27, 2022
  6. RobertIndie
    closed this as completedon Apr 21, 2022
  7. RobertIndie
    self-assigned this
    on Jun 20, 2022
  8. RobertIndie
    added a commit that references this issue on Jun 22, 2022

    [fix][client] Fix the startMessageId can't be respected as the ChunkM…

    33cf2d0
  9. codelipenghui
    added a commit that references this issue on Jun 28, 2022

    [fix][client] Fix the startMessageId can't be respected as the ChunkM…

    d7f996f
  10. nicoloboschi
    added a commit that references this issue on Jul 4, 2022

    [fix][client] Fix the startMessageId can't be respected as the ChunkM…

    fbfaa51
  11. BewareMyPower
    added a commit that references this issue on Dec 20, 2022

    [feat] PIP 107: Introduce chunk message ID (#148)

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

Metadata

Metadata

Assignees

  • @RobertIndie
    RobertIndie

Labels

lifecycle/staletype/PIP

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.