Skip to content

[feat][admin] PIP-415: Support getting message ID by index - #24222

Merged
liangyepianzhou merged 17 commits into
apache:masterfrom
liangyepianzhou:pip-415-impl
Jun 23, 2025
Merged

liangyepianzhou merged 17 commits into
apache:masterfrom
liangyepianzhou:pip-415-impl

Conversation

@liangyepianzhou

Copy link
Copy Markdown
Contributor

PIP:#24220

Motivation

we can now obtain the offset of a message by its message id:

  1. Get the message by id using get-message-by-id cmd
  2. Get the index of the message using Message.getIndex()

But we cannot obtain the message id by offset. Then we need to add a new API to get the message id by offset.

Modifications

Add a new http API to retrieve the message ID by offset.
We propose to add a new API to retrieve the message ID by offset, enabling us to cache the mapping between message ID and offset.
This will allow us to use offsets for seek and acknowledgment operations when consuming messages through the standardized API.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Apr 27, 2025
@liangyepianzhou liangyepianzhou self-assigned this Apr 27, 2025
@liangyepianzhou
liangyepianzhou marked this pull request as ready for review April 27, 2025 12:35
xiangying added 2 commits May 14, 2025 10:41

@StevenLuMT StevenLuMT left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#24220 PIP has a lot of adjustments.
@liangyepianzhou please ping me after you modify the code and I will review it again.

@liangyepianzhou liangyepianzhou changed the title [feat][admin] PIP-415: Support getting message ID by offset [feat][admin] PIP-415: Support getting message ID by index May 29, 2025
@AuroraTwinkle

Copy link
Copy Markdown
Contributor

Good jobs

@dao-jun dao-jun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small comments, Overall LGTM.
By the way, if you rely on the AppendMessageIndexInterceptor, I'd suggest you need to check whether the interceptor configured before start the broker.

@nodece nodece left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov-commenter

codecov-commenter commented Jun 23, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 72.38095% with 29 lines in your changes missing coverage. Please review.

Project coverage is 74.33%. Comparing base (bbc6224) to head (fc2420f).
Report is 1160 commits behind head on master.

Files with missing lines Patch % Lines
...pulsar/broker/admin/impl/PersistentTopicsBase.java 60.81% 19 Missing and 10 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24222      +/-   ##
============================================
+ Coverage     73.57%   74.33%   +0.76%     
- Complexity    32624    32765     +141     
============================================
  Files          1877     1868       -9     
  Lines        139502   145497    +5995     
  Branches      15299    16643    +1344     
============================================
+ Hits         102638   108157    +5519     
+ Misses        28908    28789     -119     
- Partials       7956     8551     +595     
Flag Coverage Δ
inttests 26.81% <0.00%> (+2.22%) ⬆️
systests 23.33% <0.00%> (-1.00%) ⬇️
unittests 73.82% <72.38%> (+0.97%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...pache/pulsar/broker/admin/v2/PersistentTopics.java 88.62% <100.00%> (+7.68%) ⬆️
...in/java/org/apache/pulsar/client/admin/Topics.java 80.95% <ø> (+3.45%) ⬆️
...pache/pulsar/client/admin/internal/TopicsImpl.java 84.38% <100.00%> (+2.37%) ⬆️
...in/java/org/apache/pulsar/admin/cli/CmdTopics.java 80.63% <100.00%> (-0.55%) ⬇️
...pulsar/broker/admin/impl/PersistentTopicsBase.java 70.02% <60.81%> (+4.57%) ⬆️

... and 1085 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@liangyepianzhou
liangyepianzhou merged commit ed28c21 into apache:master Jun 23, 2025
@liangyepianzhou
liangyepianzhou deleted the pip-415-impl branch June 23, 2025 06:02
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
)

PIP:apache#24220

### Motivation
 we can now obtain the offset of a message by its message id:

1. Get the message by id using `get-message-by-id` cmd
2. Get the index of the message using `Message.getIndex()`

But we cannot obtain the message id by offset. Then we need to add a new API to get the message id by offset.


### Modifications

Add a new http API to retrieve the message ID by offset.
We propose to add a new API to retrieve the message ID by offset, enabling us to cache the mapping between message ID and offset.
This will allow us to use offsets for seek and acknowledgment operations when consuming messages through the standardized API.
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
)

PIP:apache#24220

### Motivation
 we can now obtain the offset of a message by its message id:

1. Get the message by id using `get-message-by-id` cmd
2. Get the index of the message using `Message.getIndex()`

But we cannot obtain the message id by offset. Then we need to add a new API to get the message id by offset.


### Modifications

Add a new http API to retrieve the message ID by offset.
We propose to add a new API to retrieve the message ID by offset, enabling us to cache the mapping between message ID and offset.
This will allow us to use offsets for seek and acknowledgment operations when consuming messages through the standardized API.
@BewareMyPower BewareMyPower added this to the 4.2.0 milestone Oct 23, 2025
@StevenLuMT

Copy link
Copy Markdown
Member

liangyepianzhou added a commit that referenced this pull request Nov 12, 2025
PIP:#24220

 we can now obtain the offset of a message by its message id:

1. Get the message by id using `get-message-by-id` cmd
2. Get the index of the message using `Message.getIndex()`

But we cannot obtain the message id by offset. Then we need to add a new API to get the message id by offset.

Add a new http API to retrieve the message ID by offset.
We propose to add a new API to retrieve the message ID by offset, enabling us to cache the mapping between message ID and offset.
This will allow us to use offsets for seek and acknowledgment operations when consuming messages through the standardized API.

(cherry picked from commit ed28c21)
@liangyepianzhou liangyepianzhou modified the milestones: 4.2.0, 4.1.0 Nov 12, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 13, 2025
)

PIP:apache#24220

 we can now obtain the offset of a message by its message id:

1. Get the message by id using `get-message-by-id` cmd
2. Get the index of the message using `Message.getIndex()`

But we cannot obtain the message id by offset. Then we need to add a new API to get the message id by offset.

Add a new http API to retrieve the message ID by offset.
We propose to add a new API to retrieve the message ID by offset, enabling us to cache the mapping between message ID and offset.
This will allow us to use offsets for seek and acknowledgment operations when consuming messages through the standardized API.

(cherry picked from commit ed28c21)
(cherry picked from commit 8350352)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 14, 2025
)

PIP:apache#24220

 we can now obtain the offset of a message by its message id:

1. Get the message by id using `get-message-by-id` cmd
2. Get the index of the message using `Message.getIndex()`

But we cannot obtain the message id by offset. Then we need to add a new API to get the message id by offset.

Add a new http API to retrieve the message ID by offset.
We propose to add a new API to retrieve the message ID by offset, enabling us to cache the mapping between message ID and offset.
This will allow us to use offsets for seek and acknowledgment operations when consuming messages through the standardized API.

(cherry picked from commit ed28c21)
(cherry picked from commit 8350352)
FlorentinDUBOIS added a commit to CleverCloud/magnetar that referenced this pull request May 22, 2026
Implements Apache Pulsar PIP-415 as a REST admin endpoint, per upstream
intent: the spec's "Binary protocol" section is intentionally empty and
the canonical PR (apache/pulsar#24222) touches only admin/broker/CLI
Java code. No proto changes.

- AdminClient::topic_get_message_id_by_index(topic, index) -> MessageId
  hits GET /admin/v2/persistent/{tenant}/{ns}/{topic}/getMessageIdByIndex
  with the canonical Java endpoint annotation.
- Deserialise-only DTO mirrors Java's MessageIdImpl JSON shape
  ({ledgerId, entryId, partitionIndex}); batch_index/batch_size collapse
  to -1 since the broker resolves at entry granularity.
- Drive-by fix in url() helper: pop_if_empty() before pushing API
  segments. The trailing slash on /admin/v2/ left an empty sentinel
  segment that caused /admin/v2//persistent/... — tolerated by real
  brokers, rejected by strict mocks, and a divergence from Java's
  PulsarAdmin emit form. All existing admin methods inherit the fix.
- 5 wiremock-driven tests pin path, verb, query param, JSON wire shape,
  and the 412/404 error paths called out in PIP-415 §Error Responses.

Parity matrix and follow-ups updated to reflect the REST-only nature.

Signed-off-by: Florentin Dubois <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants