[ 
https://issues.apache.org/jira/browse/OPENJPA-2943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18142786#comment-18142786
 ] 

ASF subversion and git services commented on OPENJPA-2943:
----------------------------------------------------------

Commit 13bd3d2bbd2b10a63b5eb59d9d12106cf140c15c in openjpa's branch 
refs/heads/OPENJPA-2944 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=13bd3d2bb ]

[OPENJPA-2943] Keep only the store connection read-only outside of a transaction

The dictionary set every connection it decorated read-only, those of
DataSource2 included, and only a flush made one writable again. With the
broader detection the sequence allocation, schema changes, bulk and native
updates and pessimistic locks of an application with a
jdbc:mysql:replication: URL ran on read-only connections and failed with
"Cannot execute statement in a READ ONLY transaction".

The store manager now sets its own connection read-only only outside of a
transaction and makes it writable when a transaction begins, asking the
new DBDictionary.isReplicationConnection(Connection). Connections for
sequences and the schema tool are never made read-only. MySQLDictionary
recognizes a replication connection by the connection itself, unwrapping
OpenJPA's decorators, instead of the configured URL, which may belong to
another data source; the driver's interfaces are loaded once. The
configured ReplicationDriver name is only a fallback. MariaDBDictionary
recognizes a jdbc:mariadb:replication: connection by its metadata URL. The
test stub in Connector/J's package is replaced by a test-local interface.


> MySQLDictionary.decorate() is out of date with MySQL Driver Changes
> -------------------------------------------------------------------
>
>                 Key: OPENJPA-2943
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2943
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>            Reporter: Jody Grassel
>            Priority: Major
>
> MySQLDictionary.decorate() has a check to determine if the MySQL driver is of 
> type "com.mysql.jdbc.ReplicationDriver" (for utilizing read-only replica 
> nodes to relieve read-work on the primary database) – if it is, then it calls 
> conn.setReadOnly(true).  This is to ensure that, by default, reads are going 
> to the reader nodes, instead of the writer nodes.
> Later versions of the MySQL Connect J driver (as of v8) have done away with 
> the "com.mysql.jdbc.ReplicationDriver" class (see 
> [https://dev.mysql.com/doc/connector-j/en/connector-j-other-changes.html 
> section|https://dev.mysql.com/doc/connector-j/en/connector-j-other-changes.html,]).
> This means the current means of detecting whether the environment is using 
> read-replicas is no longer valid, and needs to be updated to support more 
> modern versions of Connect J.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to