V
V
vetsmen2018-03-02 12:27:03
MySQL
vetsmen, 2018-03-02 12:27:03

Question about mysql transactions?

I use mysql transactions in my node.js application, I have a few questions about them:
1) SELECT ... FOR UPDATE - At what point is the write lock released? When will I UPDATE the same entry, or when will I ROLLBACK/COMMIT the entire session of my request?
2) With the help of SELECT ... FOR UPDATE I have selected some data, but they do not satisfy me. Is it necessary to do a ROLLBACK (because, in fact, there is nowhere to return), or is it enough to close the connection of the current session of the request and the lock will be released?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2018-03-02
@vetsmen

1) Yes, the locks will be released after the end of the transaction
2) Depending on how your client is configured and what actions will be taken to disconnect. By default, as far as I remember, COMMIT will be performed when disconnecting, so doing ROLLBACK is mandatory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question