-
Notifications
You must be signed in to change notification settings - Fork 73
Fix topic lookup segmentation fault after client is closed #521
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
Fix topic lookup segmentation fault after client is closed #521
Conversation
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.
Pull Request Overview
This PR enhances the RetryableOperationCache to properly handle operations after the cache has been closed by introducing a closed_ flag and returning ResultAlreadyClosed for new operations. The method clear() is renamed to close() for consistency with other components.
Key changes:
- Renamed
clear()toclose()inRetryableOperationCacheand added aclosed_flag - Added logic to return
ResultAlreadyClosedwhenrun()is called afterclose() - Updated
ResultUtils.hto treatResultAlreadyClosedas a non-retryable (fatal) error - Added test coverage for the race condition where operations are attempted after client shutdown
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/RetryableOperationCache.h | Renamed clear() to close(), added closed_ flag, and early return with ResultAlreadyClosed when operations are attempted after close |
| lib/RetryableLookupService.h | Updated calls from clear() to close(), applied std::move optimization to constructor parameter |
| lib/ClientImpl.h | Added LookupServiceFactory type alias and test-only constructor that accepts a custom lookup service factory |
| lib/ClientImpl.cc | Refactored lookup service creation to use factory pattern, ensuring lookupServicePtr_->close() is called in shutdown() |
| lib/ResultUtils.h | Added ResultAlreadyClosed to the set of fatal (non-retryable) results |
| tests/RetryableOperationCacheTest.cc | Updated test to use close() instead of clear() |
| tests/LookupServiceTest.cc | Added tests for race conditions when operations occur after client shutdown |
Comments suppressed due to low confidence (1)
tests/RetryableOperationCacheTest.cc:121
- The test name
testClearshould be updated totestCloseto match the renamed method being tested.
TEST_F(RetryableOperationCacheTest, testClear) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
tests/RetryableOperationCacheTest.cc:121
- The test name
testClearshould be updated totestCloseto match the renamed method being tested.
TEST_F(RetryableOperationCacheTest, testClear) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
(cherry picked from commit a03eb92)
Fixes #513
Motivation
When a
ClientImplobject is destructed, theLookupServiceobject pointed by thelookupServicePtr_field will be destructed. However, if there is a pending lookup operation inRetryableOperation, it could access the destructedRetryableLookupService::lookupService_field, which is null.Modifications
RetryableLookupService::closeinClientImpl::shutdown. ImproveRetryableOperationCache::closeto fail any new operation withResultAlreadyClosedaftercloseis called.ResultAlreadyClosedto the fatal result list so thatRetryableOperationwon't retry for this error code.testAfterClientShutdownto verify the pending lookup operation will fail withResultDisconnectedaftershutdownis called because the timer is cancelled.testRetryAfterDestroyedto verify any further operation will fail withResultAlreadyClosedafterRetryableLookupService::close.