Skip to content

add clearSize Cache#604

Open
weihubeats wants to merge 1 commit into
apache:masterfrom
weihubeats:master_route_bugfix
Open

add clearSize Cache#604
weihubeats wants to merge 1 commit into
apache:masterfrom
weihubeats:master_route_bugfix

Conversation

@weihubeats

Copy link
Copy Markdown
Member

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity. It will be closed in 3 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR.

@github-actions github-actions Bot added the stale Pull request is stale label Oct 14, 2023
@weihubeats

Copy link
Copy Markdown
Member Author

Can anyone take a look at this pr?

@github-actions github-actions Bot removed the stale Pull request is stale label Oct 17, 2023
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity. It will be closed in 3 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR.

@github-actions github-actions Bot added the stale Pull request is stale label Nov 16, 2023
@lizhanhui lizhanhui added no stale This will never be considered stale and removed stale Pull request is stale labels Nov 16, 2023

@oss-sentinel-ai oss-sentinel-ai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #604 — add clearSize Cache
Type: Feature enhancement (2 files, +14)

Assessment

Adds clearSize cache support in the Go client. The change is minimal and focused on the client implementation and protobuf definition.

Verdict

✅ Clean, minimal addition. Addresses issue #603.


🤖 Automated review by oss-sentinel-ai

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review by github-manager-bot

Summary

Adds a ClearSizeCache() method to MessageQueue protobuf type and calls it during route refresh to clear stale protobuf size caches on old route entries.

Findings

  • [Warning] definition.pb.go — The ClearSizeCache() method directly manipulates protobuf internal fields (sizeCache, x.Topic.sizeCache, x.Broker.sizeCache, x.Broker.Endpoints.sizeCache). This is problematic because:

    1. sizeCache is a protobuf internal implementation detail (managed by protoimpl). Directly modifying it bypasses the protobuf runtime and may cause incorrect behavior if the runtime uses this field for lazy serialization.
    2. This method only clears 4 levels of nesting. If the protobuf structure changes or additional nested messages are added, this method will silently miss them.
    3. Thread safety: if the MessageQueue is accessed concurrently (which is common in Go client code), directly writing to sizeCache without synchronization could cause a data race.
  • [Warning] client.go — The clearOldRouteSizeCache function is called inside the route refresh callback. The naming suggests it's clearing a cache, but the actual purpose (clearing protobuf internal serialization cache) is not obvious. Consider adding a comment explaining why this is needed.

  • [Info] The PR references issue #603 but the description is minimal. Consider expanding the PR body to explain the problem (stale size cache causing incorrect behavior?) and how this fix resolves it.

Suggestions

  1. Instead of directly manipulating sizeCache, consider using protoimpl.X.MessageState() or calling Reset() followed by re-population if the goal is to force re-serialization.
  2. Add a comment explaining the motivation and the specific bug this fixes.
  3. Consider whether ClearSizeCache should be generated by protoc-gen-go plugin rather than hand-written, to stay in sync with the protobuf definition.

Automated review by github-manager-bot

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

Labels

no stale This will never be considered stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants