-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReadWriteSplitting plugin never switching to readers for Wildfly project #1096
Comments
Hi @juliendef , Thanks for reaching out and raising this issue. We'll take a look at this and keep you updated as we investigate. Thank you for your patience! |
Hi @juliendef, I've been trying to use your poc to reproduce the issue but am running into some problems. I'm not familiar with wildfly, but I'm following the steps in the poc's README to use wildfly locally. After deploying to wildfly, do I need to also run the application locally (eg through intellij)? When I do I get the below error. I've verified that Additionally, your poc README mentions using SSM to port forward RDS to your local machine. What is SSM? And is port forwarding needed even if you specify the RDS URL in the data source? So far I've been trying to run it without port forwarding by specifying the RDS URL in the data source. Error I'm seeing when running application through intellij after deploying to wildfly:
|
Hi @aaron-congo , sorry for the delay Assuming you're trying to run Wildfly locally without Docker (easiest)
No need to run on intellij if the
I mention this for my colleagues (because we don't have direct access to RDS, we're going through AWS Systems Manager Agent), but the aim is to have access from your PC to RDS. Any way you can. After that, in README, chapter /subsystem=datasources/data-source=MyPool:add(jndi-name=java:jboss/datasources/MyPool, driver-name="aws-wrapper", connection-url="jdbc:aws-wrapper:mysql://localhost:3326/myDb?wrapperLoggerLevel=ALL&wrapperPlugins=readWriteSplitting,failover,efm2")
/subsystem=datasources/data-source=MyPool:write-attribute(name=user-name, value=myUser)
/subsystem=datasources/data-source=MyPool:write-attribute(name=password, value=myPassword) The exception you share with me seems to be a problem linked to the RDS connection. Otherwise, another important point so that your endpoint |
Hi @juliendef, The problem I was encountering was because I was using the newest version of wildfly which is incompatible with your poc, I overlooked the fact that your poc uses 26.1.1 and the error I was getting didn't make that clear. After switching to 26.1.1 I was able to reproduce the problem. The key reason why your poc never switches to the reader is that "Connection.setReadOnly(true)" is never called. This is the method that needs to be used to tell our wrapper to switch to a reader connection (see docs here). I debugged one of our non-wildfly spring examples and compared it to your poc. In our example, JpaTransactionManager is used by default as the underlying transaction manager. This transaction manager automatically calls "Connection.setReadOnly(true)" when it hits a I'm not too familiar with wildfly or spring-boot, do you know if there is a way to configure your poc to use JpaTransactionManager instead of JtaTransactionManager? The key thing that needs to happen is that Connection.setReadOnly is called to switch to a reader. One more note, please see this section of our docs because there is a related limitation regarding the |
Describe the bug
Using Java 8, Spring 2.1.3, Wildfly 10.1.0, MySQL 8.0.33 and AWS advanced JDBC wrapper 2.3.9.
Note
Even using Wildfly 26.1.1, Jdk 11, Spring 2.7.1, like your example. It wont do the transaction routing.
I can't reach my reader instance at all when a transaction is indicated as “readOnly”.
There's no call for switchConnectionIfRequired, as if the plugin wasn't listening to the transactional annotation and its readOnly property.
The following logs result from a test with the minimal example from the repo I've attached below
Expected Behavior
I personally built a version containing additional logs of aws-advanced-jdbc-wrapper, observing that switchConnectionIfRequired is never called, and I expect that to be the case when
@transactional(readOnly=true)
is being calledWhat plugins are used? What other connection properties were set?
wrapperLoggerLevel=ALL&wrapperPlugins=readWriteSplitting,failover,efm2
Current Behavior
No switch is made on the reader, certainly because no call to that switchConnectionIfRequired
Reproduction Steps
Minimal example that reproduces the problem, read Wildfly on Docker chapter for fast reproduction. Feel free to ask
Possible Solution
Perhaps because of the JTA Wildfly?
Additional Information/Context
No response
The AWS Advanced JDBC Driver version used
2.3.9
JDK version used
8 (also tested on 11)
Operating System and version
CentOS Linux 7 (docker image)
The text was updated successfully, but these errors were encountered: