-
Notifications
You must be signed in to change notification settings - Fork 161
[ISSUE #768]♻️Replace SyncUnsafeCell with ArcCellWrapper🔥 #771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🚀Thanks for your contribution🎉. CodeRabbit(AI) will review your code first🔥 |
WalkthroughThe changes across the RocketMQ codebase primarily involve replacing Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (13)
- rocketmq-broker/src/broker_runtime.rs (5 hunks)
- rocketmq-broker/src/offset/manager/consumer_offset_manager.rs (8 hunks)
- rocketmq-broker/src/processor/admin_broker_processor/topic_request_handler.rs (3 hunks)
- rocketmq-broker/src/processor/pull_message_processor.rs (6 hunks)
- rocketmq-broker/src/topic/manager/topic_config_manager.rs (13 hunks)
- rocketmq-common/src/lib.rs (3 hunks)
- rocketmq-remoting/src/protocol/command_custom_header.rs (1 hunks)
- rocketmq-remoting/src/protocol/remoting_command.rs (9 hunks)
- rocketmq-remoting/src/rpc/rpc_client_impl.rs (7 hunks)
- rocketmq-remoting/src/rpc/rpc_response.rs (2 hunks)
- rocketmq-remoting/src/runtime/server.rs (6 hunks)
- rocketmq-store/src/log_file/mapped_file/default_impl.rs (7 hunks)
- rocketmq-store/src/queue.rs (1 hunks)
Additional comments not posted (68)
rocketmq-remoting/src/rpc/rpc_response.rs (5)
18-18
: LGTM: Addedstd::any::Any
import.The import is necessary for dynamic typing and type casting.
27-27
: LGTM: Updatedheader
field to useArcCellWrapper
.This change enhances thread safety and mutable state management.
35-35
: LGTM: Updated trait bounds to includeAny
.This allows for dynamic type checking and casting.
Also applies to: 48-48
40-41
: LGTM: Updatedget_header
andget_header_mut
to useArcCellWrapper
.This ensures safe mutable access and thread safety.
Also applies to: 53-54
70-70
: LGTM: Updatednew
method to useBox<dyn CommandCustomHeader>
andArcCellWrapper
.This aligns with the new usage of
ArcCellWrapper
for managing mutable state.Also applies to: 75-75
rocketmq-remoting/src/protocol/command_custom_header.rs (2)
17-17
: LGTM: Addedstd::any::Any
import.The import is necessary for dynamic typing and type casting.
22-22
: LGTM: UpdatedCommandCustomHeader
to extendAny
.This allows for dynamic type checking and casting of
CommandCustomHeader
objects.rocketmq-common/src/lib.rs (9)
22-22
: LGTM: Added necessary imports forWeakCellWrapper
andArcCellWrapper
.These imports are required for the implementation of
WeakCellWrapper
andArcCellWrapper
.Also applies to: 27-27
51-53
: LGTM: IntroducedWeakCellWrapper
andArcCellWrapper
structs.These structs provide safer concurrent access and modification of shared state.
Also applies to: 55-61, 63-69, 71-87
76-80
: LGTM: Implementedmut_from_ref
method forArcCellWrapper
.This method allows mutable access to the wrapped value.
Line range hint
88-97
: LGTM: Implementednew
,Clone
,AsRef
,AsMut
,Deref
, andDerefMut
forArcCellWrapper
.These implementations provide essential functionality for creating and using
ArcCellWrapper
.
131-133
: LGTM: IntroducedSyncUnsafeCellWrapper
struct.This struct provides a wrapper around
SyncUnsafeCell
for safer concurrent access.
135-141
: LGTM: Implementednew
method forSyncUnsafeCellWrapper
.This method allows for the creation of a new
SyncUnsafeCellWrapper
instance.
145-148
: LGTM: Implementedmut_from_ref
method forSyncUnsafeCellWrapper
.This method allows mutable access to the wrapped value.
151-154
: LGTM: ImplementedAsRef
forSyncUnsafeCellWrapper
.This implementation allows immutable access to the wrapped value.
157-160
: LGTM: ImplementedAsMut
forSyncUnsafeCellWrapper
.This implementation allows mutable access to the wrapped value.
rocketmq-remoting/src/runtime/server.rs (3)
25-26
: LGTM: Added necessary imports forArcCellWrapper
andWeakCellWrapper
.These imports are required for the usage of
ArcCellWrapper
andWeakCellWrapper
.
52-56
: LGTM: UpdatedConnectionHandlerContext
andconnection_handler_context
to useWeakCellWrapper
andArcCellWrapper
.These changes enhance thread safety and mutable state management.
80-80
: LGTM: Updatedhandle
method andConnectionListener
struct to useArcCellWrapper
.These changes ensure safe mutable access and thread safety.
Also applies to: 103-103, 112-112, 171-173
rocketmq-store/src/queue.rs (1)
Line range hint
14-14
:
Verify the reasoning behind reverting toArc<SyncUnsafeCell>
.The type definition for
ArcConsumeQueue
has been changed fromArcCellWrapper<Box<dyn ConsumeQueueTrait>>
toArc<SyncUnsafeCell<Box<dyn ConsumeQueueTrait>>>
. Ensure this change aligns with the project's requirements and doesn't reintroduce previous issues.rocketmq-broker/src/processor/admin_broker_processor/topic_request_handler.rs (3)
166-170
: LGTM!The changes to use
as_ref()
before cloningdata_version
ensure that the reference is cloned correctly.
268-272
: LGTM!The changes to use
as_ref()
before cloningdata_version
ensure that the reference is cloned correctly.
375-381
: LGTM!The changes to use
as_ref()
before cloningdata_version
ensure that the reference is cloned correctly.rocketmq-broker/src/offset/manager/consumer_offset_manager.rs (5)
63-63
: LGTM!The changes to replace
SyncUnsafeCell
withArcCellWrapper
fordata_version
ensure safer concurrent access and modification.
146-148
: LGTM!The changes to use
mut_from_ref()
fordata_version
ensure that the mutable reference is obtained correctly.
217-218
: LGTM!The changes to use
mut_from_ref()
andas_ref()
fordata_version
ensure that the references are obtained correctly.
258-260
: LGTM!The changes to replace
SyncUnsafeCell
withArcCellWrapper
fordata_version
ensure safer concurrent access and modification.
395-395
: LGTM!The changes to replace
SyncUnsafeCell
withArcCellWrapper
fordata_version
ensure safer concurrent access and modification.rocketmq-remoting/src/rpc/rpc_client_impl.rs (7)
105-106
: LGTM!The changes to pass
response_header
as a boxed trait object ensure that the trait object is passed correctly.
142-143
: LGTM!The changes to pass
response_header
as a boxed trait object ensure that the trait object is passed correctly.
178-179
: LGTM!The changes to pass
response_header
as a boxed trait object ensure that the trait object is passed correctly.
214-215
: LGTM!The changes to pass
response_header
as a boxed trait object ensure that the trait object is passed correctly.
250-251
: LGTM!The changes to pass
response_header
as a boxed trait object ensure that the trait object is passed correctly.
286-287
: LGTM!The changes to pass
response_header
as a boxed trait object ensure that the trait object is passed correctly.
326-327
: LGTM!The changes to pass
response_header
as a boxed trait object ensure that the trait object is passed correctly.rocketmq-remoting/src/protocol/remoting_command.rs (9)
30-30
: Import statement forArcCellWrapper
is approved.The import statement is necessary for the changes made in this file.
96-96
: Change toArcCellWrapper
forcommand_custom_header
is approved.The change improves safety and maintainability by using
ArcCellWrapper
.
219-219
: Update toset_command_custom_header
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
226-226
: Update toset_command_custom_header_origin
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
237-237
: Update toset_command_custom_header_ref
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
539-545
: Update toread_custom_header
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
552-558
: Update toread_custom_header_mut
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
565-565
: Update tocommand_custom_header_ref
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
570-572
: Update tocommand_custom_header_mut
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.rocketmq-broker/src/topic/manager/topic_config_manager.rs (11)
31-31
: Import statement forArcCellWrapper
is approved.The import statement is necessary for the changes made in this file.
48-48
: Change toArcCellWrapper
fordata_version
is approved.The change improves safety and maintainability by using
ArcCellWrapper
.
77-77
: Update todata_version
initialization is approved.The initialization is updated to use
ArcCellWrapper
, consistent with the overall transition.
234-234
: Update tobuild_serialize_wrapper_with_topic_queue_map
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
299-299
: Update tocreate_topic_in_send_message_method
is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
360-360
: Update tocreate_topic_in_send_message_back_method
is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
413-414
: Update todelete_topic_config
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
445-445
: Update toupdate_topic_config
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
534-535
: Update todata_version
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
551-551
: Update toencode_pretty
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.
569-569
: Update todecode
method is approved.The method is updated to use
ArcCellWrapper
, consistent with the overall transition.rocketmq-store/src/log_file/mapped_file/default_impl.rs (6)
34-34
: Import statement forSyncUnsafeCellWrapper
is approved.The import statement is necessary for the changes made in this file.
59-59
: Change toSyncUnsafeCellWrapper
formmapped_file
is approved.The change improves safety and maintainability by using
SyncUnsafeCellWrapper
.
112-112
: Update tommapped_file
initialization is approved.The initialization is updated to use
SyncUnsafeCellWrapper
, consistent with the overall transition.
196-196
: Update tommapped_file
initialization innew_with_transient_store_pool
is approved.The initialization is updated to use
SyncUnsafeCellWrapper
, consistent with the overall transition.
587-587
: Update toget_mapped_file_mut
method is approved.The method is updated to use
SyncUnsafeCellWrapper
, consistent with the overall transition.
591-591
: Update toget_mapped_file
method is approved.The method is updated to use
SyncUnsafeCellWrapper
, consistent with the overall transition.rocketmq-broker/src/processor/pull_message_processor.rs (4)
24-24
: Import ofArcCellWrapper
looks good.The import statement for
ArcCellWrapper
is consistent with the PR objective.
71-71
: Update topull_message_result_handler
type looks good.The change to
ArcCellWrapper<Box<dyn PullMessageResultHandler>>
aligns with the objective to replaceSyncUnsafeCell
withArcCellWrapper
.
87-87
: Constructor update looks good.The constructor now accepts
ArcCellWrapper<Box<dyn PullMessageResultHandler>>
, which is consistent with the updated struct definition.
761-761
: Verify the removal ofpull_message_result_handler
method.Ensure that the removal of this method doesn't impact the functionality.
rocketmq-broker/src/broker_runtime.rs (3)
Line range hint
17-31
:
Import Changes AcknowledgedThe import statements now include
std::any::Any
androcketmq_common::ArcCellWrapper
. These changes are necessary for the transition fromSyncUnsafeCell
toArcCellWrapper
.
379-388
: Initialization ofpull_message_result_handler
UpdatedThe
pull_message_result_handler
is now initialized usingArcCellWrapper
and cast asBox<dyn PullMessageResultHandler>
. This change enhances safety and maintainability.
419-423
: Type Casting ofpull_message_result_handler
The
pull_message_result_handler
is cast todyn Any
and then downcast toDefaultPullMessageResultHandler
. This is necessary for setting thepull_request_hold_service
.
Which Issue(s) This PR Fixes(Closes)
Fixes #768
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
New Features
ArcCellWrapper
across several modules.Improvements
SyncUnsafeCell
withArcCellWrapper
.TopicRequestHandler
methods for better data version management.Code Clean-up