I have a MySQL transaction that continuously runs in a loop every second and does the following:
- BEGIN
- SELECT ... FOR UPDATE LIMIT 100;
- application code early returns if (2) returns 0 rows
- UPDATE SET ....
- COMMIT
I am not explicitly closing the transaction when I early return in step 2. Are there any side effects I should be concerned about? I shouldn't be holding on to any locks because the SELECT did not return any rows. Do I need to be concerned about these unclosed transactions building up on the database somewhere? Do they timeout automatically?