Skip to content

在client filter耗时比较长且业务请求超时配置比较短的情况下, 全链路超时取默认值的逻辑会造成框架行为不符合预期 #4516

@JianhuaGong

Description

@JianhuaGong

在servicecomb.invocation.timeout未配置时,而全链路超时时间默认取值为2倍的request.timeout,当request.timeout配置较小时(很多业务配置较小),只要客户端client filter执行时间稍微长一点,就会造成请求报408,不符合使用预期,也与历史行为不一致。

当前的代码如下:

  private void guardedWait(Invocation invocation) throws InvocationException {
    long wait = getWaitTime(invocation);
    try {
      if (wait <= 0) {
        latch.await();
        return;
      }
      if (latch.await(wait, TimeUnit.MILLISECONDS)) {
        return;
      }
    } catch (InterruptedException e) {
      //ignore
    }
    throw new InvocationException(REQUEST_TIMEOUT, ExceptionCodes.INVOCATION_TIMEOUT, "Invocation Timeout.");
  }

  private long getWaitTime(Invocation invocation) {
    if (invocation.getOperationMeta().getConfig().getMsInvocationTimeout() > 0) {
      return invocation.getOperationMeta().getConfig().getMsInvocationTimeout();
    }

    return invocation.getOperationMeta().getConfig().getMsRequestTimeout() * 2;
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions