Skip to content

channelz: ServerData calls_failed counter not incremented upon client cancellation #13063

Description

@jdcormie

What version of gRPC are you using?

HEAD

What did you expect to see?

Per grpc/channelz/v1/channelz.proto (ServerData):

// ServerData is data for a specific Server.
message ServerData {
  ...
  // The number of incoming calls started on the server
  int64 calls_started = 2;
  // The number of incoming calls that have completed with an OK status
  int64 calls_succeeded = 3;
  // The number of incoming calls that have a completed with a non-OK status
  int64 calls_failed = 4;
  ...

When an incoming RPC terminates due to client cancellation, transport reset, or client-side deadline expiration, the call terminates with non-OK status (Status.CANCELLED). I expect this situation to be reflected in calls_failed.

What did you see instead?

calls_started increments when the call arrives at the server. However, when a call is cancelled by the client before the server application closes, neither calls_succeeded nor calls_failed is incremented.

Client cancellations or timeouts are not unusual. So on any long-lived server, calls_started - calls_succeeded - calls_failed grows larger and larger over time.

Steps to reproduce

For ServerCallImplTest.java

  @Test
  public void callTracer_clientCancelled_reportsCallFailed() {
    ServerStreamListenerImpl<Long> streamListener =
        new ServerCallImpl.ServerStreamListenerImpl<>(call, callListener, context);

    streamListener.closed(Status.CANCELLED);

    ServerStats.Builder afterBuilder = new ServerStats.Builder();
    serverCallTracer.updateBuilder(afterBuilder);
    ServerStats after = afterBuilder.build();
    assertEquals(1, after.callsStarted);
    assertEquals(0, after.callsSucceeded);
    assertEquals(1, after.callsFailed); // <--- Fails. Actual value is 0.
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions