add clearSize Cache#604
Conversation
|
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. |
|
Can anyone take a look at this pr? |
|
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. |
oss-sentinel-ai
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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— TheClearSizeCache()method directly manipulates protobuf internal fields (sizeCache,x.Topic.sizeCache,x.Broker.sizeCache,x.Broker.Endpoints.sizeCache). This is problematic because:sizeCacheis a protobuf internal implementation detail (managed byprotoimpl). Directly modifying it bypasses the protobuf runtime and may cause incorrect behavior if the runtime uses this field for lazy serialization.- 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.
- Thread safety: if the
MessageQueueis accessed concurrently (which is common in Go client code), directly writing tosizeCachewithout synchronization could cause a data race.
-
[Warning]
client.go— TheclearOldRouteSizeCachefunction 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
- Instead of directly manipulating
sizeCache, consider usingprotoimpl.X.MessageState()or callingReset()followed by re-population if the goal is to force re-serialization. - Add a comment explaining the motivation and the specific bug this fixes.
- Consider whether
ClearSizeCacheshould be generated byprotoc-gen-goplugin rather than hand-written, to stay in sync with the protobuf definition.
Automated review by github-manager-bot
#603