[MXS-1866] Prepared statements do not work Created: 2018-05-11  Updated: 2018-05-18  Resolved: 2018-05-18

Status: Closed
Project: MariaDB MaxScale
Component/s: readconnroute
Affects Version/s: 2.2.5
Fix Version/s: 2.2.6

Type: Bug Priority: Major
Reporter: Bob Sauvage Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None
Environment:

RHEL 7
JBoss 6.1
Java 6
mariadb-java-client-1.7.3.jar
MariaDB 10.2.13


Attachments: Text File Java_Error.txt    
Sprint: MXS-SPRINT-58

 Description   

Hi there,

I'm in simple setup. Two hosts: one master, one slave. All requests (W/R) are forwarded to the master.

Here is my config:

[maxscale]
threads=auto
logdir=/var/log/maxscale/
piddir=/var/run/maxscale/
 
[xxx1]
type=server
address=192.168.82.1
port=3306
protocol=MariaDBBackend
serv_weight=1
 
[xxxx2]
type=server
address=192.168.3.1
port=3306
protocol=MariaDBBackend
serv_weight=0
 
[MariaDB-Monitor]
type=monitor
module=mariadbmon
servers=xxxx1,xxxx2
user=xxx
passwd=xxx
monitor_interval=2000
auto_failover=true
detect_standalone_master=true
auto_rejoin=true
replication_user=replicator
replication_password=xxxx
 
[Readconn-Router-Service]
type=service
router=readconnroute
servers=xxxx1,xxxx2
router_options=master
user=maxboy
passwd=xxxx
weightby=serv_weight
 
[MaxAdmin-Service]
type=service
router=cli
 
[CLI]
type=service
router=cli
 
[RRS-Listener]
type=listener
service=Readconn-Router-Service
protocol=MariaDBClient
port=3306
address=127.0.0.1
 
[MaxAdmin-Listener]
type=listener
service=MaxAdmin-Service
protocol=maxscaled
socket=default
 
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
address=localhost
port=6603

When executing a batch of prepared statements from my application, I encounter a JAVA Exception.

You will find the Exception as an attachment.



 Comments   
Comment by Bob Sauvage [ 2018-05-11 ]

I've activated all logs in MaxScale. I cannot see the prepared statement.

I've activate the general_log in MariaDB, I see the prepared statement:

Prepare insert into JBPM_BYTEBLOCK (PROCESSFILE_, INDEX_, BYTES_) values (?, ?, ?)

I've activated slow log on MariaDB (>0), I don't see the request with the parameters... While I see it when by passing MaxScale...

Comment by markus makela [ 2018-05-12 ]

Possibly a problem with batch execution of statements. Adding useBatchMultiSend=false to the connection string would verify this.

Comment by Bob Sauvage [ 2018-05-12 ]

@markus makela Thanks for your quick reply

I've added the option like this in the configuration of my datasource in JBoss:

<connection-url>jdbc:mariadb://127.0.0.1:3306/MyDB?useBatchMultiSend=false</connection-url>

but it is not working better :/

I'm surprized that the option does not appear in the boot.log. Normal ?

Thanks,

Bob

Comment by markus makela [ 2018-05-15 ]

If you add version_string=10.1.30-fake-version to the service, does it fix it?

The likely cause is the fact that MaxScale 2.2 does not treat the COM_STMT_BULK_EXECUTE correctly.

Comment by Bob Sauvage [ 2018-05-15 ]

@Markus Makela

Have I to add it to maxscale.cnf ?

[maxscale]
...
version_string=10.1.30-fake-version

If yes, the error continues to appear:

ERROR hibernate flush failed: org.hibernate.exception.JDBCConnectionException: Could not execute JDBC batch update

Have I to test another version of Maxscale ?

Comment by Bob Sauvage [ 2018-05-15 ]

Markus,

It's working, thanks a lot !

The parameter was to add in the service section.

Do you know if I risk to encounter other issues during failover due to this "bug" ?

In order to remove this parameter safely, have I to wait a new release of MaxScale ?

Again, thanks for your support.

Comment by markus makela [ 2018-05-15 ]

The new style of bulk insert/update added for the 10.2.7 release of MariaDB is not currently supported by MaxScale (it doesn't treat it as a prepared statement command). Using a version string of an older release guarantees that the connector (if it's smart enough) won't use this new command. The connector can also be configured to not use this command by adding useBulkStmts=false but this has to be done on all clients that use MaxScale.

Given that this appears to be a relatively simple bug to fix so I would assume it'll be a part of either the next 2.2 release or the one after that. MaxScale versions prior to 2.2 should work with this as they don't load balance prepared statements and hence don't really care about "unknown" commands (they are treated as if they were writes →they are routed to the master).

Comment by Bob Sauvage [ 2018-05-16 ]

Thanks a lot for your complete answer and the time you took to explain me the issue and the future actions.

Generated at Thu Feb 08 04:09:59 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.