Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statement unsafe for statement based replication #107

Open
stevenwilliamson opened this issue May 25, 2015 · 0 comments
Open

Statement unsafe for statement based replication #107

stevenwilliamson opened this issue May 25, 2015 · 0 comments

Comments

@stevenwilliamson
Copy link

When running against MySQL >= 5.1 with STATEMENT based replication the MySQL server logs the following error:

150514 22:59:37 [Warning] Statement may not be safe to log in statement format. Statement: UPDATE delayed_jobs SET locked_at = '2015-05-14 22:59:38', locked_by = 'host:job1-dev.test.host' pid:24358' WHERE ((run_at <= '2015-05-14 22:59:38' AND (locked_at IS NULL OR locked_at < '2015-05-14 22:39:38') OR locked_by = 'host:job1-dev.test.host pid:24358') AND failed_at IS NULL) ORDER BY priority ASC, run_at ASC LIMIT 1

This is due to non deterministic behaviour of this statement on the master and slave due to the limit 1 and the potential for rows to be returned in a different order.

Appending the id field to the order by will resolve the issue because this field is unique, so rows will always be returned in the same order on the slave as on the master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant