0

In a transaction, for example,

START TRANSACTION; SELECT count(*) as count FROM `order` WHERE user_id = 25286 LOCK IN SHARE MODE; INSERT INTO `order` (`id`, `user_id`, `product_id`) VALUES (NULL, '25286', '36296');

we perform the SELECT LOCK IN SHARE MODE; the SELECT query will be executed on the slave database and lock a row.

Does the SELECT LOCK IN SHARE MODE also create a row locking on the master database so that the INSERT query will not run on a master database?

  • No query on the slave can affect the master. – danblack Oct 15 '18 at 6:53
0

There is no communication from Slave to Master (aside from network protocols to receive the Replication updates from the Master.

Writing on a Slave is a no-no. The basic principle of Replication is that the Slave will have exactly (except for a slight lag) the same data as the Master. Writing to the Slave does not allow for keeping them in sync.

An exception is with Master-Master -- wherein two servers are acting both as Master and as Slave. Still, writing to both leads to a lot of potential problems, and should be avoided.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.