Skip to content

[ISSUE #11037] Encode delay message propertiesString after clearing internal properties - #11505

Open
lihanyu1715446406-afk wants to merge 2 commits into
apache:developfrom
lihanyu1715446406-afk:fix/delay-properties-string-after-clear
Open

lihanyu1715446406-afk wants to merge 2 commits into
apache:developfrom
lihanyu1715446406-afk:fix/delay-properties-string-after-clear

Conversation

@lihanyu1715446406-afk

Copy link
Copy Markdown

What is the purpose of the change

ScheduleMessageService#messageTimeUp encodes propertiesString from msgExt.getProperties() before removing the internal scheduling properties. MessageAccessor.clearProperty only removes entries from the in-memory property map, so the encoded wire data — which is what gets persisted and decoded by consumers — still carries DELAY_TIME_LEVEL, TIMER_DELIVER_MS and TIMER_DELAY_SEC.

Move the encoding after the clearProperty calls and encode msgInner.getProperties(), matching the ordering already used by TimerMessageStore#convertMessage (the timer-wheel path fixed in #10972).

Brief changelog

  • Encode propertiesString after the internal properties are cleared.
  • Add ScheduleMessageServiceTest#testMessageTimeUpPropertiesStringMatchesProperties, which asserts that the delivered message's propertiesString contains none of the internal properties and equals a re-encoding of the final property map.

Verifications

  • Without the production change, the new test fails with AssertionError on assertFalse(delivered.getPropertiesString().contains(PROPERTY_DELAY_TIME_LEVEL)).
  • With the change: Tests run: 5, Failures: 0, Errors: 0, Skipped: 0.

Fixes #11037.

Note: an earlier attempt, #11038, was closed unmerged. This PR is an independent implementation of the fix with a regression test, as the issue is still open.

…ring internal properties

ScheduleMessageService#messageTimeUp encoded msgInner.propertiesString from
msgExt.getProperties() before PROPERTY_DELAY_TIME_LEVEL,
PROPERTY_TIMER_DELIVER_MS and PROPERTY_TIMER_DELAY_SEC were cleared.
MessageAccessor.clearProperty only removes entries from the property map,
so the persisted wire data kept the internal properties while the in-memory
map did not.

Encode after the properties are finalized, matching the ordering already
used by TimerMessageStore#convertMessage. Add a regression test that
asserts the delivered propertiesString contains none of the internal
properties and equals a re-encoding of the final property map.
@lihanyu1715446406-afk

Copy link
Copy Markdown
Author

Friendly ping — could a committer approve the CI run for this PR? The regression test fails without the production change and passes with it. Happy to adjust anything if needed.

@lihanyu1715446406-afk

Copy link
Copy Markdown
Author

Local verification on this branch (JDK 17):

  • mvn -pl broker -am test -Dtest=ScheduleMessageServiceTest — 5/5 pass, including the new testMessageTimeUpPropertiesStringMatchesProperties.
  • Restoring the original ordering (setPropertiesString from msgExt.getProperties() before the clearProperty calls) makes the new test fail with java.lang.AssertionError, so it pins the regression.
  • mvn -pl broker -am validate — 0 Checkstyle violations.

One process item is still blocking the PR: every pull-request workflow run (Build and Run Tests by Maven, Run Integration Tests, CodeQL, ...) is in action_required state waiting for approval, since this is my first contribution to Apache RocketMQ. Could a committer approve the workflow runs so the checks can report? Happy to adjust anything if the CI surfaces an issue.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.80%. Comparing base (0e839a9) to head (c43b2c0).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11505      +/-   ##
=============================================
- Coverage      49.87%   49.80%   -0.08%     
+ Complexity     14420    14405      -15     
=============================================
  Files           1391     1391              
  Lines         103361   103361              
  Branches       13519    13519              
=============================================
- Hits           51554    51478      -76     
- Misses         45601    45665      +64     
- Partials        6206     6218      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lihanyu1715446406-afk

Copy link
Copy Markdown
Author

@RongtongJin Gentle nudge on this one — the only remaining blocker is that the CI workflow needs a maintainer approval for this fork PR. Local verification on JDK 17 is already in the thread (mvn -pl broker -am test -Dtest=ScheduleMessageServiceTest → 5/5, including the new regression test that fails without the production change).

If the preferred fix is different from encoding propertiesString after clearing internal properties, I'm happy to rework it — just let me know.

@RongtongJin

Copy link
Copy Markdown
Contributor

Thanks for following up. CI is green now, and I also ran ScheduleMessageServiceTest on JDK 17. All five tests passed. I agree that encoding before clearing the scheduling properties leaves stale data in the commit log. I found two consumer-visible changes that I'd like us to address before merging.

I sent a message with delay level 2 and WAIT=true, read it back from the real topic after delivery, and passed it through GrpcConverter.

Value after delivery Before With this PR
Stored DELAY property 2 absent
isWaitStoreMsgOK() true false
gRPC SystemProperties.message_type DELAY NORMAL
  1. Could we preserve the original stored WAIT value by clearing the scheduling properties, encoding them, and then calling setWaitStoreMsgOK(false) for the broker's internal put? This matters because the Java push consumer copies the delivered properties when it falls back to sendMessageBackAsNormalMessage. An inherited WAIT=false can make that retry return before synchronous flush or replication completes.
  2. Could you cover the gRPC receive path and clarify the intended message type after delivery? GrpcConverter derives it from the stored properties, so removing DELAY changes what a client sees for a delay-level message. I'd like to preserve the existing DELAY response unless we explicitly agree to change that API behavior.

The existing testDeliverDelayedMessageTimerTask already reads and decodes the delivered message, which makes it a good place to check the stored properties. In the new test, please also set PROPERTY_TIMER_DELAY_SEC on the input and check decoded keys so the assertion exercises its removal.

@lihanyu1715446406-afk

Copy link
Copy Markdown
Author

Thanks for reproducing the consumer-visible differences. I agree about WAIT: I will clear the scheduling properties, serialize while the original WAIT value is still present, and only then call setWaitStoreMsgOK(false) for the broker's internal put. I will assert the decoded delivered properties (including WAIT and TIMER_DELAY_SEC) in the existing delivery test.

For message_type, I traced GrpcConverter#buildSystemProperties to TopicMessageType.parseFromMessageProperty. In this path it identifies DELAY only from the scheduling properties that #11037 asks us to remove from the persisted real-topic message. Once they are removed, the converter has no remaining indication that this was originally delayed. Preserving both the old gRPC DELAY result and the no-leak behavior would require a separate durable origin signal or a broader converter change.

Which contract should this PR follow: preserve the stored DELAY property for compatibility (narrowing #11037), or remove it as the issue requests and treat the delivered message as NORMAL? I can implement and test the WAIT correction while we settle that behavior.

@lihanyu1715446406-afk

Copy link
Copy Markdown
Author

Pushed 97c1f143 to address the WAIT behavior:

  • Clear the scheduling properties, serialize the finalized properties while the original WAIT=true is retained, then set the in-memory flag to false for the broker's internal put.
  • Extend the delivery test to verify the decoded stored properties retain WAIT=true and omit DELAY_TIME_LEVEL, TIMER_DELIVER_MS, and TIMER_DELAY_SEC; also verify the internal put flag is false.

The gRPC message_type question remains as described above. I will keep the current no-scheduling-properties behavior unless you prefer preserving the stored DELAY marker for compatibility, which would narrow the fix for #11037.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Delay messages are delivered with internal properties leaked into propertiesString (ScheduleMessageService#messageTimeUp)

3 participants