Skip to content

[POP] Restart Broker may will cause that consumer consumes from first #3503

@cserwen

Description

@cserwen

BUG REPORT

  1. Please describe the issue you observed:
  • What did you do (The steps to reproduce)?
    Restart the broker when consumer is running

  • What did you expect to see?
    The consumer continues to consume from the last offset

  • What did you see instead?
    It consumed from 0

  1. Please tell us about your environment:
    Linux

  2. Other information (e.g. detailed explanation, logs, related issues, suggestions how to fix, etc):

2021-11-17 20:16:12 WARN PullMessageThread_21 - Pop initial offset, because store is no correct, pop-1@consumer@3, 5384577->null
2021-11-17 20:16:12 WARN PullMessageThread_69 - Pop initial offset, because store is no correct, pop-1@consumer@2, 5384587->null
2021-11-17 20:16:12 WARN PullMessageThread_3 - Pop initial offset, because store is no correct, pop-1@consumer@0, 26128469->null
2021-11-17 20:16:12 WARN PullMessageThread_31 - Pop initial offset, because store is no correct, pop-1@consumer@1, 12384558->null
2021-11-17 20:16:12 WARN PullMessageThread_78 - Pop initial offset, because store is no correct, %RETRY%consumer_pop-1@consumer@0, 143690->null

getMessage() will return null when:

public GetMessageResult getMessage(final String group, final String topic, final int queueId, final long offset,
        final int maxMsgNums,
        final MessageFilter messageFilter) {
        if (this.shutdown) {
            log.warn("message store has shutdown, so getMessage is forbidden");
            return null;
        }

        if (!this.runningFlags.isReadable()) {
            log.warn("message store is not readable, so getMessage is forbidden " + this.runningFlags.getFlagBits());
            return null;
        }
        ...

I think that the offset should not be set as 0 when this method return null.

public GetMessageResult getMessage(final String group, final String topic, final int queueId, final long offset,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions