Google Spanner 最简单的查询超时错误

huangapple go评论67阅读模式
英文:

Google Spanner Deadline Exceeded with simplest queries

问题

我正在在Spring Boot应用程序中使用GCP+R2DBC。这是我的代码的简化版本:

public class WidgetDetailsCustomRepositoryImpl implements WidgetDetailsCustomRepository {

    private final WidgetDetailsRepository widgetDetailsRepository;

    private final R2dbcEntityTemplate r2dbcEntityTemplate;

    private Mono<WidgetDetailsModel> saveWidgetDetails(WidgetDetailsModel widgetDetailsModel) {
        Mono<WidgetDetailsModel> result = widgetDetailsRepository.existsById(widgetDetailsModel.getWidgetTrackingNumber())
                .flatMap(widgetExists -> {
                    if (widgetExists) {
                        log.info("Updating WidgetDetails: {}", widgetDetailsModel.getWidgetTrackingNumber());
                        return r2dbcEntityTemplate.update(widgetDetailsModel);
                    } else {
                        log.info("Inserting WidgetDetails: {}", widgetDetailsModel.getWidgetTrackingNumber());
                        return r2dbcEntityTemplate.insert(widgetDetailsModel);
                    }
                });
    }
}

在existsById()方法中,大约19秒后我收到了DEADLINE_EXCEEDED错误。对于findById()方法,我也遇到了类似的问题。明确一下,我不是在执行复杂查询,而是在一个Spanner表中精确地获取、保存或更新一条记录。我的CPU使用率约为1.5%,这是一个基于开发的项目。此外,单个记录有大约10列,字符数不超过255个字符。

在同一个项目中,我可以成功地从PubSub订阅中获取消息。我提到这一点是为了强调,我没有像GCP的故障排除指南中提到的那样遇到任何网络问题。

有人谈论过更改RPC重试值,但他们没有提到如何在R2DBC中更改这些值。我知道有一些JSON文件,但他们没有说明如何指定自己的值,例如。

此外,还有一个"Spanner健康检查失败"的消息。这是来自GCP库中的某个地方的消息,表明我做错了什么。

GCP说要在某个blockingStub对象上指定重试关闭。我没有进行任何阻塞调用。最简单的调用都会因为DEADLINE_EXCEEDED错误而失败。

简而言之,我已经验证了网络连接。我已经验证了CPU使用率。是否有一些神奇的R2DBC+Spanner设置我需要做?

英文:

I'm using GCP+R2DBC in a Spring Boot application. This is a simplified version of my code:

public class WidgetDetailsCustomRepositoryImpl implements WidgetDetailsCustomRepository {

    private final WidgetDetailsRepository widgetDetailsRepository;

    private final R2dbcEntityTemplate r2dbcEntityTemplate;

    private Mono&lt;WidgetDetailsModel&gt; saveWidgetDetails(WidgetDetailsModel widgetDetailsModel) {
        Mono&lt;WidgetDetailsModel&gt; result = widgetDetailsRepository.existsById(widgetDetailsModel.getWidgetTrackingNumber())
                .flatMap(widgetExists -&gt; {
                    if (widgetExists) {
                        log.info(&quot;Updating WidgetDetails: {}&quot;, widgetDetailsModel.getWidgetTrackingNumber());
                        return r2dbcEntityTemplate.update(widgetDetailsModel);
                    } else {
                        log.info(&quot;Inserting WidgetDetails: {}&quot;, widgetDetailsModel.getWidgetTrackingNumber());
                        return r2dbcEntityTemplate.insert(widgetDetailsModel);
                    }
                });

    }
}

I get a DEADLINE_EXCEEDED error after about 19s on the existsById(). I get something similar for a findById(). To be clear, I'm not doing a complex query, rather fetch, save or update exactly 1 record in a spanner table. My CPU usage is about 1.5% and this is a dev based project. Also, a single record has about 10 columns and is less than about 255 characters.

In the same project, I can successfully fetch a message from a PubSub subscription. I mention this to emphasize that I'm not having any network issues as mentioned in the troubleshooting guide from GCP.

There was talk about changing the RPC retry values, but they fail to mention how to change these things for R2DBC. I realize there's some JSON files, but they don't say how to, for eg. specify your own values.

Also, there is a "Spanner health check failed" message. This is coming from somewhere in a GCP library, suggesting that I did something wrong.

GCP does say to specify retry off some blockingStub object. I'm not doing any blocking calls. The simplest of calls fails with a DEADLINE_EXCEEDED error.

In short, I verified network connectivity. I verified CPU usage. Is there some magic R2DBC+Spanner setting I need to do?

答案1

得分: 1

这很可能是在尝试进行身份验证或刷新OAuth令牌时发生超时错误所致。19秒(或接近20秒)的超时时间对应于该默认超时时间。

在标准的Cloud Spanner客户端中,没有与约19秒相对应的默认超时时间。

您的应用程序使用什么类型的身份验证?您确定您使用的凭据具有访问Cloud Spanner数据库的权限吗?

英文:

This is most likely caused by a timeout error while trying to authenticate or refresh the OAuth token. The 19 seconds (or close to 20 seconds) timeout corresponds with the default timeout for that.

There is no default timeout in the standard Cloud Spanner client that corresponds with approx 19 seconds.

What kind of authentication is your application using? Are you sure the credentials that you are using have access to the Cloud Spanner database?

huangapple
  • 本文由 发表于 2023年6月16日 13:04:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76487087.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定