aschenmaker opened a new pull request, #3776:
URL: https://github.com/apache/brpc/pull/3776

   ### What problem does this PR solve?
   
   Issue Number: resolve #3775
   
   Problem Summary:
   When `ListOfABAFreeId<Id, IdTraits>::add(Id id)` triggers GC (`_nblock * 
IdTraits::BLOCK_SIZE > _next_gc_size`), it calls `gc()` and directly returns 
`rc` (`0`) without inserting the pending `id` into the newly compacted list. 
Because `gc()` only migrates existing live IDs, the newly added `id` is 
silently dropped even though `add()` reports success.
   
   For `Socket::_id_wait_list` (`bthread_id_list_t`), this causes 
`Socket::NotifyOnFailed()` to skip both list registration and the `rc != 0` 
fallback `bthread_id_error()`. If the socket subsequently fails, the omitted 
RPC ID will never be notified by `bthread_id_list_reset2_pthreadsafe()`.
   
   ### What is changed and the side effects?
   
   Changed:
   - `src/bthread/list_of_abafree_id.h`: After `gc()` succeeds (`rc == 0`), 
write `id` into `_cur_block->ids[_cur_index]` and call `forward_index()` before 
returning `0`. At the end of `gc()`, `add_to_temp_list()` guarantees 
`_cur_block->ids[_cur_index]` is an initialized empty slot (`ID_INIT`).
   - `test/abalist_unittest.cc`: Added `AbaListTest.TestGcPreservesAddedIds`, 
which verifies after every `add()` returning `0` that `apply()` visits every 
live accepted ID (both all-live and churn scenarios).
   
   Side effects:
   - Performance effects: None (only one slot assignment and index advance 
after GC).
   
   - Breaking backward compatibility: None.
   
   ---
   ### Check List:
   - Please make sure your changes are compilable.
   - When providing us with a new feature, it is best to add related tests.
   - Please follow [Contributor Covenant Code of 
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to