[fix](brpc) Make secondary package aliases non-owning#65777
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
/review |
|
run buildall |
71712a5 to
6d54960
Compare
|
run buildall |
|
Updated this PR based on the DORIS-27128 TLS/cloud context. The previous variant regression retry change was removed; the PR now fixes OSS BE/cloud starter handling for protocols excluded by tls_excluded_protocols. |
|
/review |
6d54960 to
f3ba3c2
Compare
|
Codex automated review failed and did not complete. Error: Codex completed, but no new pull request review was submitted for the current head SHA. Please inspect the workflow logs and rerun the review after the underlying issue is resolved. |
|
Corrected again after reviewing the secondary_package shutdown path. The TLS starter change has been removed. This PR now fixes the brpc secondary_package_name patch by making secondary service/method aliases non-owning, avoiding double delete during brpc::Server::ClearServices(). |
|
run buildall |
|
/review |
|
Codex automated review failed and did not complete. Error: Codex completed, but no new pull request review was submitted for the current head SHA. Please inspect the workflow logs and rerun the review after the underlying issue is resolved. |
There was a problem hiding this comment.
Automated review result: request changes
The normal destructor path is improved: when primary and secondary names are distinct, the patch leaves one owner and avoids the duplicate deletes. Three issues still need resolution:
- Explicit
RemoveServiceand registration rollback leave the new aliases in BRPC maps after shared targets are deleted, enabling stale lookup andStart()use-after-free. - If
secondary_package_nameequals the primary package,FlatMapassignment overwrites the only owning entries with non-owning copies. - The Cloud lifecycle test still disables the exact non-empty alias branch, so lookup and owned teardown are untested.
Critical checkpoint conclusions:
- Goal and tests: the direct
ClearServicesdouble-free is addressed, but runtime regression coverage and removal/error paths are incomplete. - Scope and clarity: this is one focused patch; method and service ownership changes are symmetrical.
- Lifecycle and error handling: M-001 is blocking; cleanup must cover explicit removal and every rollback.
- Concurrency: no new race or lock issue was found; BRPC mutation is
READY-only and destruction stops/joins beforeClearServices. - Configuration and compatibility: no protocol or storage-format change applies; M-002 is the uncovered configuration edge. No persistence, transaction, FE/BE propagation, data-write, observability, or material performance issue applies.
- Testing: static review only under the runner contract;
thirdparty/installedandprotocare absent. Cloud UT does not cover the changed branch because the test clears the configuration. - User focus: no additional focus was provided; the full PR was reviewed.
Review completion: the single changed file and its BRPC/Cloud upstream and downstream paths were reviewed through three rounds; every candidate was accepted, deduplicated, or dismissed with evidence. The three accepted points are attached inline.
| + _fullname_service_map[secondary_full_name] = ss; | ||
| + ServiceProperty secondary_ss = ss; | ||
| + secondary_ss.ownership = SERVER_DOESNT_OWN_SERVICE; | ||
| + _fullname_service_map[secondary_full_name] = secondary_ss; |
There was a problem hiding this comment.
[P1] Erase these aliases when removing the service
Making the alias non-owning avoids the destructor double free, but BRPC 1.4.0 RemoveMethodsOf erases only md->full_name() (plus the IDL no-namespace alias), and RemoveService erases only sd->full_name()/sd->name(). Therefore AddService with a secondary package followed by RemoveService—or an AddServiceInternal rollback—deletes the primary MethodStatus and, on owning removal paths, the service while these secondary map entries remain. A later Find* returns dangling state, and Start() dereferences the freed status/service. Please track and erase the secondary method and service keys on every removal/rollback before deleting the shared objects.
| + secondary_method_name.append(md->name()); | ||
| + _method_map[secondary_method_name] = mp; | ||
| + MethodProperty secondary_mp = mp; | ||
| + secondary_mp.own_method_status = false; |
There was a problem hiding this comment.
[P2] Preserve ownership when the alias equals the primary package
secondary_package_name is unrestricted; for MetaService, setting it to its current package doris.cloud makes secondary_full_name equal sd->full_name() and the derived method keys equal md->full_name(). FlatMap::operator[] then overwrites the just-inserted owning entries with these non-owning copies, so ClearServices/RemoveService no longer deletes the MethodStatus or the SERVER_OWNS_SERVICE allocation. Reject or skip an alias equal to the primary name before assigning it, and preflight any other alias-key collision.
| + secondary_method_name.push_back('.'); | ||
| + secondary_method_name.append(md->name()); | ||
| + _method_map[secondary_method_name] = mp; | ||
| + MethodProperty secondary_mp = mp; |
There was a problem hiding this comment.
[P2] Add a runtime regression for this ownership branch
The Cloud lifecycle test currently forces config::secondary_package_name = "" specifically to avoid brpc::Server::~Server() crashing, so no test executes this changed non-owning branch. The reported patch-apply check proves only that the third-party patch applies. Please enable a distinct non-empty alias in a test, assert both service/method names resolve, and destroy or ClearServices() an owning server; the removal and equal-package cases above should also be covered.
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
Proposed changes
Fix DORIS-27128 in the brpc secondary package alias implementation.
The existing brpc secondary_package_name patch registers the secondary service name by copying the primary ServiceProperty, and registers secondary methods by copying the primary MethodProperty as owning entries. During brpc::Server destruction, ClearServices() iterates all service and method map entries:
This matches the cloud MetaService secondary package shutdown/coredump path. The patch now makes secondary aliases non-owning:
The previous variant regression retry change and the TLS starter change have both been removed from this PR.
Testing
Issue: DORIS-27128