这个问题通常出现在 AWS Aurora MySQL 数据库中,它会阻止读取器(Reader)连接到写入器(Writer),从而导致读取失败。
要解决这个问题,可以通过以下的步骤来完成。
第一步:使用以下代码查询连接池中的读写器地址(Writer Endpoint 和 Reader Endpoint)。
show global status like '%aurora_endpoint%';
第二步:确保只使用 Reader Endpoint 进行读取操作,而不是 Write EndPoint。
例如,使用以下代码将 AWS SDK 的连接器配置为使用 Reader Endpoint:
AmazonRDSClientBuilder builder = AmazonRDSClientBuilder.standard().withCredentials(credentials);
String readerEndpoint = "
这个方法将确保只使用Reader Endpoint 进行读取操作,而不是将它们转发到 Writer。