Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves robustness by safer parsing of the auto-discovery environment variable, adding memory unregistration cleanup on mount failures, and checking the return status of the HTTP metadata server startup. The review comments correctly identify a compilation error where hasResult() is called on a std::optional instead of has_value(), and suggest using a C++ style const_cast instead of a C-style cast.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| server_->async_start(); | ||
| auto ec = server_->async_start(); | ||
| if (ec.hasResult()) { |
There was a problem hiding this comment.
std::optional does not have a hasResult() method in the C++ Standard Library. Using ec.hasResult() will result in a compilation error. Since server_->async_start() returns a std::optional<std::error_code>, you should check if it contains an error using ec.has_value() or simply if (ec).
| if (ec.hasResult()) { | |
| if (ec.has_value()) { |
There was a problem hiding this comment.
async_start() returns async_simple::Future<coro_rpc::err_code>, not std::optional. hasResult() is a method on that type. This exact pattern is used in 5+ other call sites: master_service_supervisor.cpp:410, rpc_service.cpp:233, real_client.cpp:1644, rpc_communicator.cpp:138, test_server_helpers.h:176.
| LOG(ERROR) << "mount_segment_to_master_failed base=" << buffer | ||
| << " size=" << size << ", error=" << err; | ||
| int unreg_rc = | ||
| transfer_engine_->unregisterLocalMemory((void*)buffer); |
There was a problem hiding this comment.
In C++, it is preferred to use C++ style casts instead of C-style casts. Consider using const_cast<void*>(buffer) instead of (void*)buffer to cast away the const qualifier.
| transfer_engine_->unregisterLocalMemory((void*)buffer); | |
| transfer_engine_->unregisterLocalMemory(const_cast<void*>(buffer)); |
There was a problem hiding this comment.
Good point. Changed both sites to const_cast<void*>(buffer) in 6cc538a.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| LOG(ERROR) << "mount_segment_to_master_failed base=" << buffer | ||
| << " size=" << size << ", error=" << err; | ||
| int unreg_rc = transfer_engine_->unregisterLocalMemory( | ||
| const_cast<void*>(buffer)); |
There was a problem hiding this comment.
Thanks for this work.
The issue of "RDMA memory leak on MountSegment failure" does indeed exist and is a known problem. However, we do not yet have a good solution for fixing it.
Simply unregistering the memory after an RPC failure may introduce another issue: the operation may have actually succeeded on the master side, but the network could fail while the result is being returned to the client. In that case, the client would unregister the memory, while the master still considers the operation successful, leaving the system in an inconsistent state.
There was a problem hiding this comment.
Good point — the network-failure-after-master-success scenario is a real concern. The current fix assumes RPC failure = operation failed, which is not always true.
I can remove the unregisterLocalMemory cleanup from this PR to keep it safe. The other two changes in this PR (strtol guard for MC_MS_AUTO_DISC, const_cast) are independent and uncontroversial.
For the RDMA memory leak on MountSegment failure, a proper fix would likely need idempotent mount/retry or a reconciliation mechanism with the master. Happy to defer that to a separate discussion/issue.
46aa7aa to
b17e9ad
Compare
- Fix memory registration leak in MountSegmentAndGetId: call unregisterLocalMemory when MountSegment RPC fails, preventing permanent RDMA-pinned memory leak on transient master errors. - Replace unguarded std::stoi with strtol in get_auto_discover: setting MC_MS_AUTO_DISC="true" no longer crashes the process. - Check async_start() return in HttpMetadataServer::start(): port-bind failures are now reported instead of silently ignored. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address review: log WARNING if unregisterLocalMemory fails during MountSegment error cleanup, matching UnmountSegmentImpl pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per reviewer feedback: RPC failure does not guarantee the master didn't succeed. Unregistering could leave master/client state inconsistent. Tracked in kvcache-ai#2364. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4bb47f8 to
7fa3d93
Compare
|
Gentle ping @ykwd — the earlier test-wheel failure was environmental and CI is now green after a re-run. This PR fixes a crash on non-numeric MC_MS_AUTO_DISC and a silent async_start failure. Would appreciate a follow-up review when convenient. Thanks! |
|
Closing this PR — both fixes have been superseded on main:
Thanks @ykwd for the earlier review, and apologies for the noise from yesterday's ping — the overlap with #2942 surfaced during a rebase check today. |
Summary
MC_MS_AUTO_DISC(client_service.cpp):get_auto_discover()used unguardedstd::stoi, which throwsstd::invalid_argumenton inputs like"true"or"yes". Replaced withstrtol+ error checking, matchingGetConfiguredNumaSocketIdpattern in the same file.async_start()return inHttpMetadataServer::start()(http_metadata_server.cpp): Port-bind failures were silently ignored. Now checksec.hasResult()and returns false, matchingrpc_service.cpp:233andreal_client.cpp:1644patterns.What's NOT changed
Test plan