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

   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Problem Summary:
   
   1. `Socket::DebugSocket()` (the builtin `/sockets/<SocketId>` page) 
described the socket's parsing context from the bthread serving the HTTP 
request, while the bthread parsing messages of that socket could reset or 
release the context at the same time (e.g. `InputMessenger` resetting it before 
trying other protocols). The context, including an `H2Context` with its mutexes 
and HPACK state, could be destroyed while being described.
   2. `ProcessMongoRequest()` runs in a different bthread from the one parsing 
messages of the socket, but read the `MongoContext` from the socket's parsing 
context, which the parsing bthread may reset in the meantime.
   
   ### What is changed and the side effects?
   
   Changed:
   - Add `Socket::_parsing_context_mutex`. `reset_parsing_context()` and 
`release_parsing_context()` hold it while taking the context out of the socket 
(`Destroy()` still runs after unlocking), and `DebugSocket()` holds it while 
loading and describing the context, so a context is destroyed or handed off 
only after the description is done.
   - Add `MongoInputMessage`, which carries an `intrusive_ptr<MongoContext>` 
referenced in `ParseMongoMessage()` on the parsing bthread. 
`ProcessMongoRequest()` uses that reference instead of reading the socket's 
parsing context.
   - Add `SocketTest.debug_socket_keeps_parsing_context_alive` and 
`MongoTest.process_request_after_parsing_context_reset`.
   
   Side effects:
   - Performance effects: none on hot paths. The new lock is only contended 
while `/sockets` describes that very socket.
   
   - 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).
   
   Tests run:
   - `cmake -S . -B build -DBUILD_UNIT_TESTS=ON -DDOWNLOAD_GTEST=OFF 
-DBRPC_SYSTEM_GTEST_SOURCE_DIR=/usr/src/googletest && make -j6 
brpc_socket_unittest brpc_mongo_protocol_unittest`
   - `./test/brpc_socket_unittest` (24 tests passed)
   - `./test/brpc_mongo_protocol_unittest` (6 tests passed)
   
   ---
   🤖 This PR was automatically created by brpc-oncall


-- 
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