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<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);
}
});
}
}
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?