Bug #50332 | ORDER BY RAND() with explicit RAND_SEEDs produces different results | ||
---|---|---|---|
Submitted: | 14 Jan 2010 14:43 | Modified: | 4 Feb 2010 5:47 |
Reporter: | Elena Stepanova | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Replication | Severity: | S3 (Non-critical) |
Version: | 5.5.1-m2, Celosia | OS: | Linux |
Assigned to: | Zhenxing He | CPU Architecture: | Any |
[14 Jan 2010 14:43]
Elena Stepanova
[14 Jan 2010 14:45]
Elena Stepanova
Perl script to execute the described scenarios
Attachment: 50332_rand_test.tar.gz (application/gzip, text), 228.37 KiB.
[4 Feb 2010 5:09]
Zhenxing He
If run test case 'A' several times, the result order can be different too. I think this problem is caused by different records order, we can also have similar issue when using SELECT ... LIMIT n; See also bug#49222
[4 Feb 2010 12:24]
Elena Stepanova
Hi, I checked out the bug#49222 before submitting this one, and I could not see how it related to the problem described here. The bug#49222 says that RAND() is to be marked unsafe because pre-setting seeds "is not enough in cases where the value of RAND() is inserted into several rows, because the order in which rows are retreived is not specified". There are no such inserts in the provided test case, and the order in which rows are retrieved is specified (albeit, by the very same RAND()). I also checked the documentation on rand_seed1 and rand_seed2, and the manual still says: "The purpose of these variables is to support replication of the RAND() function. For statements that invoke RAND(), the master passes two values to the slave, where they are used to seed the random number generator. The slave uses these values to set the session variables rand_seed1 and rand_seed2 so that RAND() on the slave generates the same value as on the master." http://dev.mysql.com/doc/refman/5.5/en/server-session-variables.html#sysvar_rand_seed1 I've never got different results while running test case A myself, but if you can see that, I would think that it shows that I was wrong about what triggers the problem (different replication-related settings on the server), but the problem itself still exists, just becomes wider...