Skip to content

readWriteSplitting plugin is unable to connect to reader host if enabled iam authentication #1253

Closed
@smaliebsco

Description

@smaliebsco

Describe the bug

readWriteSplitting plugin works fine with master username and password but fails to connect reader instance with IAM authentication plugging. It falls back to the writer's instance and the application works by redirecting all the queries to writer's instance

Getting error as

    The plugin was unable to establish a reader connection to any reader instance.
    Failed to switch to a reader. The plugin was unable to establish a reader connection to any reader instance.. The current writer will be used as a fallback

I am using Spring and below are the datasource configs:

    hikari:
      data-source-properties:
        autoSortWrapperPluginOrder: true
        wrapperPlugins: iam,readWriteSplitting,failover,efm,auroraConnectionTracker,initialConnection
        wrapperDialect: aurora-mysql
        readerHostSelectorStrategy: random # is configured only for internal pooling
        readerInitialConnectionHostSelectorStrategy: random
        dynamicHostListProvider: com.amazonaws.jdbc.AwsWrapperDataSource

and using the @Trasactional(readOnly=true)

It seems I have the right policy configured for IAM authenticate rds-connect as its able to establish the connection with writer intance.

Expected Behavior

It should be able to connect to reader instances and redirect queries to the reader

What plugins are used? What other connection properties were set?

iam,readWriteSplitting,failover,efm,auroraConnectionTracker,initialConnection

Current Behavior

The plugin was unable to establish a reader connection to any reader instance.

Failed to switch to a reader. The plugin was unable to establish a reader connection to any reader instance.. The current writer will be used as a fallback

"software.amazon.jdbc.plugin.readwritesplitting.ReadWriteSplittingPlugin","message":"Failed to switch to a reader. The plugin was unable to establish a reader connection to any reader instance.. The current writer will be used as a fallback:

Reproduction Steps

configure the iam, and readwritesplit plugin with 1 reader and 1 writer instance and try to redirect to the reader using the annotation

@transactional(readOnly=true)

Possible Solution

No response

Additional Information/Context

No response

The AWS Advanced JDBC Driver version used

2.5.4

JDK version used

17

Operating System and version

Docker

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions