Mysql : innodb_autoinc_lock_mode = 1 and statement based replication.

Hi all,

I have to run this query for up to 4million rows in a online production database:  "insert into t1 select from t2",
t1 has ID autoincrement column and  already has some data.

we have statement based replication.

knowing that t1 will be accessed by other users during the query run.
will this lock the table during the query run or create data discrepancies between the master and the slave??

thanks
CCVOIPAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

theGhost_k8Database ConsultantCommented:
The innodb_autoinc_lock mode you specified is the default one. 1 is consecutive mode. I'd quote documentation here:

This lock mode ensures that, in the presence of INSERT statements where the number of rows is not known in advance (and where auto-increment numbers are assigned as the statement progresses), all auto-increment values assigned by any “INSERT-like” statement are consecutive, and operations are safe for statement-based replication.
Ref: Documentation.
So, as long as it reads "Safe statement" you're good for you slaves.

Additionally, if your slave is for read-only purpose, use "read_only=ON;" ( & in 5.7 super_read_only too.)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.