apache / linkis

Apache Linkis builds a computation middleware layer to facilitate connection, governance and orchestration between the upper applications and the underlying data engines.
https://linkis.apache.org/
Apache License 2.0
3.3k stars 1.17k forks source link

[Bug] Linkis gateway throw 500 Server Error #4153

Closed guoshupei closed 1 year ago

guoshupei commented 1 year ago

Search before asking

Linkis Component

linkis-spring-cloud-services

Steps to reproduce

error log: 500 Server Error for HTTP POST "/api/rest_j/v1/entrance/submit" java.util.NoSuchElementException: None.get

image

Expected behavior

no error

Your environment

Anything else

No response

Are you willing to submit a PR?

github-actions[bot] commented 1 year ago

:blush: Welcome to the Apache Linkis community!!

We are glad that you are contributing by opening this issue.

Please make sure to include all the relevant context. We will be here shortly.

If you are interested in contributing to our website project, please let us know! You can check out our contributing guide on :point_right: How to Participate in Project Contribution.

Community

WeChat Assistant WeChat Public Account

Mailing Lists

Name Description Subscribe Unsubscribe Archive
dev@linkis.apache.org community activity information subscribe unsubscribe archive
guoshupei commented 1 year ago

The root cause is that the ribbon's ServerList is not refreshed in time

First, you can add default handle of super.choose(serviceInstance.getApplicationName, hint)

      override def choose(serviceId: String, hint: Any): client.ServiceInstance = {
        if (isMergeModuleInstance(serviceId)) {
          val serviceInstance = getServiceInstance(serviceId)
          logger.info("redirect to " + serviceInstance)
          val lb = this.getLoadBalancer(serviceInstance.getApplicationName)
          val serverOption =
            lb.getAllServers.asScala.find(_.getHostPort == serviceInstance.getInstance)
          if (serverOption.isDefined) {
            val server = serverOption.get
            new RibbonLoadBalancerClient.RibbonServer(
              serviceId,
              server,
              isSecure(server, serviceId),
              serverIntrospectorFun(serviceId).getMetadata(server)
            )
          } else {
            // add default handle
            logger.warn("RibbonLoadBalancer not have Server, execute default super choose method" + serviceInstance)
            super.choose(serviceInstance.getApplicationName, hint)
          }
        } else super.choose(serviceId, hint)
      }

Second, you can shorten the refresh time in application-linkis.yml, default 30s

ribbon:
  ServerListRefreshInterval: 10000