Repository navigation
fix(server): send gRPC proxy requests to the session that owns them - #736
omkargaikwad23 wants to merge 6 commits into
Conversation
VerificationI ran the same script on
Local tests:
|
_session_queues checked for a session key and then read it in a second step. A session can end in a different thread between the two steps, and the caller then got a KeyError. Each decision now reads PROXY_QUEUES one time, so the caller gets the "session is not active" error.
| f"The proxy session {self.session_id!r} is not active.") | ||
| return queues | ||
| queues = PROXY_QUEUES.get(rpc_id_var.get()) | ||
| if queues is not None: |
There was a problem hiding this comment.
This fallback still sends prompts to another session. A model has no session_id when it is built through get_generator (oneshot, interact, dataagent orchestrators), and Interact only checks the generator, not the orchestrator.
Checked the method with two sessions A and B and a model without session_id:
- both live, caller B: gets B's queues
- B disconnects (
_cleanup_on_droppops B, its worker threads keep running), caller B: gets A's queues - same with
session_id=B:RuntimeError, which is what we want
So after B drops, B's remaining prompts go to A's client. If both run the same dataset the conversation IDs collide too, and B's thread replaces A's inbox for that ID.
Lets remove the single session fallback and raise. test_model_without_identity_uses_the_only_session then changes to expect the error.
There was a problem hiding this comment.
Good catch, I could reproduce it: after B drops, a model without a session ID got A's queues. Fixed in 84f50dd, the single-session fallback is gone and it raises now. One side effect: grpc_proxy with the oneshot, interact, or dataagent orchestrator now fails, because the model has no session ID or RPC ID there. Cortado is not affected.
A model with no session ID used the only active session. After its own session ended, that was the session of another client. Now the model uses its session ID, or the RPC ID of the caller. If no active session has that ID, the request fails.
|
/gcbrun |
1 similar comment
|
/gcbrun |
What
GrpcProxyModelsends each request to the queues of its own session.Interacthandler puts the session ID into the config, and the Cortado evaluator gives that config to the model.RuntimeError. There is no fallback to a different session.Why
The model sent each request to the first active session. With two
Interactsessions at the same time, the prompts of the second session went to the client of the first session. The second session then got the answers of that client.Behavior change: a
grpc_proxymodel with no session ID and no RPC ID now fails. Before, it used the first active session. This applies to a model thatget_generatorbuilds in theoneshot,interact, anddataagentorchestrators, because their worker threads do not have the RPC ID. The Cortado evaluator is not affected.Testing
grpc_proxy_session_test.py: 5 tests pass. With 9 related test files: 158 tests pass.pycodestyleis clean.mainRuntimeErrorRuntimeErrorInteractstreams through the eval server.Logs (Google-internal): https://paste.googleplex.com/6755399437647068