Make gRPC code-mode notifications fire-and-forget (#37906)

## What changed

- Send notification events without waiting for client acknowledgment, so an
  unacknowledged notification no longer delays cell completion.
- Keep the notification acknowledgment RPC as a compatibility no-op after
  validating the session and notification ID.
- Remove pending-notification tracking and cancellation events from the gRPC
  session routing path.

## Testing

- Verify that a cell completes after emitting an unacknowledged notification
  and that a later acknowledgment is still accepted.

GitOrigin-RevId: 19cf3ed5ce82cf45d84fa75f238c2afa4e83acb5
This commit is contained in:
Channing Conger
2026-08-11 00:52:35 +00:00
committed by copyberry
parent 260261ed8f
commit 9be95745fb
5 changed files with 32 additions and 168 deletions
@@ -237,71 +237,4 @@ impl GrpcSession {
);
}
}
pub(super) async fn begin_notification(
&self,
notification_id: Uuid,
notification: proto::Notification,
response: oneshot::Sender<()>,
cancellation: &CancellationToken,
) -> Result<(), String> {
{
let mut state = self.state.lock().unwrap_or_else(PoisonError::into_inner);
state
.pending_notifications
.insert(notification_id, response);
state.seen_notifications.remember(notification_id);
}
if let Err(error) = self
.send_event(
proto::session_event::Event::Notification(notification),
cancellation,
)
.await
{
self.state
.lock()
.unwrap_or_else(PoisonError::into_inner)
.pending_notifications
.remove(&notification_id);
return Err(error);
}
Ok(())
}
pub(super) fn acknowledge_notification(&self, notification_id: Uuid) -> Result<(), Status> {
let response = {
let mut state = self.state.lock().unwrap_or_else(PoisonError::into_inner);
match state.pending_notifications.remove(&notification_id) {
Some(response) => Some(response),
None if state.seen_notifications.contains(&notification_id) => None,
None => {
return Err(Status::not_found(format!(
"unknown code-mode notification {notification_id}"
)));
}
}
};
if let Some(response) = response {
let _ = response.send(());
}
Ok(())
}
pub(super) fn cancel_notification(&self, notification_id: Uuid) {
let pending = self
.state
.lock()
.unwrap_or_else(PoisonError::into_inner)
.pending_notifications
.remove(&notification_id);
if pending.is_some() {
let _ = self.send_event_now(
proto::session_event::Event::NotificationCancelled(proto::NotificationCancelled {
notification_id: notification_id.to_string(),
}),
/*cell_permit*/ None,
);
}
}
}