Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-419

Insert Query failed after failover and not able to get master connection

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.5.6
    • 2.1.0, 1.6.3
    • Failover
    • None
    • AWS Aurora
      Spring JdbcTemplate and SimpleJdbcCall
      rewriteBatchedStatements=true
      Execute INSERT query using jdbcTemplate
      Execute Stored Procedure using SimpleJdbcCall

    Description

      Inserting records failed after failover and throws an exception as following;
      SQL state [HY000]; error code [1290]; (conn:6) The MySQL server is running with the --read-only option so it cannot execute this statement

      Any exception starting with '08xxx' or '25Sxxx' handled and reset connection. Error code '1290' is treated general SQL exception and eventually application instance should be restarted to fix it.
      In AuroraProtocol, it passes MustBeMasterConnection before executing query but it seems not used to validate the master connection.
      Please help me if I missed any parameters in connection configuration.

      Attachments

        Issue Links

          Activity

            Diego,

            I have emailed to you the requested log file. Note that I can only reproduce this problem as part of our standard automation test suite. So at this point I suspect there is a very particular sequence of events that results in this problem. Hopefully the log file will help you out.

            I did not explicitly set "failOnReadOnly" (or "failOverReadOnly" for that matter).

            Paul

            pbj Paul B Johnson added a comment - Diego, I have emailed to you the requested log file. Note that I can only reproduce this problem as part of our standard automation test suite. So at this point I suspect there is a very particular sequence of events that results in this problem. Hopefully the log file will help you out. I did not explicitly set "failOnReadOnly" (or "failOverReadOnly" for that matter). Paul
            diego dupin Diego Dupin added a comment -

            Hi Paul,

            Thanks for the logs, i'll check them in detail tomorrow now. I hope to bring good news next time.

            Diego.

            diego dupin Diego Dupin added a comment - Hi Paul, Thanks for the logs, i'll check them in detail tomorrow now. I hope to bring good news next time. Diego.

            Note that since I have found and implemented the work-around of not calling "findOne()", our failover tests all pass. Thus the issue has become less of a priority, and more "academic" in nature. We just hope that there are not similar, but non-resolved, issues lurking.

            pbj Paul B Johnson added a comment - Note that since I have found and implemented the work-around of not calling "findOne()", our failover tests all pass. Thus the issue has become less of a priority, and more "academic" in nature. We just hope that there are not similar, but non-resolved, issues lurking.
            diego dupin Diego Dupin added a comment - - edited

            See spring-data documentation about @Transactional.
            Persisting and deleting objects requires a transaction in JPA. Thus we need to make sure a transaction is running, which we do by having the method annotated with @Transactional.

            Methods that will insert/update database will have to be marked as @Transactional ( = readOnly=false).
            If method contain find* and save methods without explicit @Transactional (without readOnly=true) then transaction will use the one initiated with find*, resulting in an exception ("The MySQL server is running with the --read-only option so it cannot execute this statement" using aurora). This isn't related to failover but to load balancing (read and write) to be distributed over multiple servers. .

            find* methods, that have implicit @Transactional(readOnly = true), Spring-data will call driver Connection.setReadOnly(true) methods.

            When using masters/slaves configuration (like aurora) query will be launched on a slave(replica) server.
            Update/insert will then fail with an exception

            Adding "@Transactional(readOnly = false)" or just "@Transactional" will solve the issue.

            diego dupin Diego Dupin added a comment - - edited See spring-data documentation about @Transactional. Persisting and deleting objects requires a transaction in JPA. Thus we need to make sure a transaction is running, which we do by having the method annotated with @Transactional. Methods that will insert/update database will have to be marked as @Transactional ( = readOnly=false). If method contain find* and save methods without explicit @Transactional (without readOnly=true) then transaction will use the one initiated with find*, resulting in an exception ("The MySQL server is running with the --read-only option so it cannot execute this statement" using aurora). This isn't related to failover but to load balancing (read and write) to be distributed over multiple servers. . find* methods, that have implicit @Transactional(readOnly = true), Spring-data will call driver Connection.setReadOnly(true) methods. When using masters/slaves configuration (like aurora) query will be launched on a slave(replica) server. Update/insert will then fail with an exception Adding "@Transactional(readOnly = false)" or just "@Transactional" will solve the issue.
            diego dupin Diego Dupin added a comment -

            Description correspond to CONJ-502 that is now corrected

            diego dupin Diego Dupin added a comment - Description correspond to CONJ-502 that is now corrected

            People

              diego dupin Diego Dupin
              seanderson Seonmi Anderson
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.