Bug #51266 Random loadBalanceStrategy does not work
Submitted: 18 Feb 2010 5:08 Modified: 12 Aug 2010 14:16
Reporter: Bogdan Degtyariov Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:5.1.10,5.1.11 OS:Any
Assigned to: CPU Architecture:Any
Tags: loadBalanceStrategy

[18 Feb 2010 5:08] Bogdan Degtyariov
Description:
Connector/J 5.1.10/5.1.11 always connects to the same host with loadBalanceStrategy=random.

Version 5.1.7 did it randomly.

How to repeat:
See the attached test case (loadbalance_bug.java).

Output for Connector/J 5.1.11 (port is always 3306):
-----------------------------------------------------
START
Connecting.....DONE
hostname: i64 port: 3306 
Disconnect

Connecting.....DONE
hostname: i64 port: 3306 
Disconnect

Connecting.....DONE
hostname: i64 port: 3306 
Disconnect

Connecting.....DONE
hostname: i64 port: 3306 
Disconnect

Connecting.....DONE
hostname: i64 port: 3306 
Disconnect

FINISH

Output for Connector/J 5.1.7 (ports are randomly picked):
-----------------------------------------------------
START
Connecting.....DONE
hostname: i64 port: 3307 
Disconnect

Connecting.....DONE
hostname: i64 port: 3307 
Disconnect

Connecting.....DONE
hostname: i64 port: 3308 
Disconnect

Connecting.....DONE
hostname: i64 port: 3306 
Disconnect

Connecting.....DONE
hostname: i64 port: 3306 
Disconnect

FINISH
[18 Feb 2010 5:18] Bogdan Degtyariov
test case

Attachment: loadbalance_bug.java (text/x-java), 1.78 KiB.

[18 Feb 2010 17:05] Mark Matthews
Fixed in the branch, for release in 5.1.13.
[23 Feb 2010 17:03] Tony Bedford
An entry has been added to the 5.1.13 changelog:

jdbc:mysql:loadbalance:// would connect to the same host, even though loadBalanceStrategy was set to a value of random, and multiple hosts were specified.
[6 May 2010 9:00] Arnault Jeanson
Hi,

I did the same test to check it and i dont' find the same results. For me loadbalacing is working but it it only switches from a threslhold.
In my bench, i made 5000 open/close connexion and loadbalaincing start to work since the 3496 e connexion. Is it really a bug ? 

Bench done in : 15219 ms
Driver version : 5.1.10
Jdbc url : jdbc:mysql:loadbalance://localhost:3306,localhost:3307/dsa?autoReconnectForPools=false&loadBalanceStrategy=random&loadBalanceBlacklistTimeout=5000
Hit 3306: 3570(71%)
First Hit 3306: 1
Hit 3307: 1430(28%)
First Hit 3307: 3496
Total: 5000

Arnault J.
[26 Jun 2010 7:40] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100626073921-t0e6q2c9nkhuemnj) (version source revid:alik@sun.com-20100626073921-t0e6q2c9nkhuemnj) (pib:16)
[4 Aug 2010 8:03] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:alik@sun.com-20100626073921-t0e6q2c9nkhuemnj) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 8:19] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:alik@sun.com-20100626073921-t0e6q2c9nkhuemnj) (merge vers: 5.6.99-m4) (pib:18)