# Innodb transaction problem

**URL:** <https://forums.percona.com/t/innodb-transaction-problem/1235>\
**Category:** Other MySQL® Questions\
**Created:** [August 11, 2009, 6:30pm UTC](https://forums.percona.com/t/innodb-transaction-problem/1235 "2009-08-11T18:30:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![moazam](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@moazam](https://forums.percona.com/u/moazam)\
**Post date:** [August 11, 2009, 6:30pm UTC](https://forums.percona.com/t/innodb-transaction-problem/1235/1 "2009-08-11T18:30:37Z")

</div>

Hello,  
I read in the book High Performance MySQL, Second Edition that innodb transactions are reliable but its not the same case on my side. On my website i am sending three sql commands to mysql server.  
2 Inserts, and one update. Innodb skip the update sql (MOST of the time, NOT all the time) and commits the transaction.

I am using set autocommit = 1 and here are mysql statements

> Begin

Q1: INSERT INTO files (`file_title`, ‘file\_date’) VALUES(‘new file’, NOW());

> $id = mysql\_insert\_id();  
> Q2: UPDATE user\_info SET `total_media`=`total_media`+1, `file_size`=$file\_size WHERE id=13;  
> Q3: INSERT INTO keywords (file\_id, keyword) VALUES ($id, ‘keyword’)

if(mysql\_query-\>query($q1) && mysql\_query($q2) && mysql\_query($q3)) {

> COMMIT;  
> }  
> else {  
> ROLLBACK;  
> }

Above code is just for understanding and all numeric fields are Integers.

Please help me on this.

Thanks,  
Moazam

---

<div class="post-metadata">

**Author:** ![gmouse](https://avatars.discourse-cdn.com/v4/letter/g/b9e5f3/32.png) [@gmouse](https://forums.percona.com/u/gmouse)\
**Post date:** [August 12, 2009, 4:49am UTC](https://forums.percona.com/t/innodb-transaction-problem/1235/2 "2009-08-12T04:49:24Z")

</div>

| [B]Quote:[/B] |
| mysql\_query-\>query |

Some dataabse class?

Anyways, the error is in your code. InnoDB would not be deployed anywhere if it would not return an error if UPDATE fails.

Note that COMMIT and ROLLBACK do not have any use if autocommit=1. Read [URL][http://dev.mysql.com/doc/refman/5.1/en/commit.html[/URL]](http://dev.mysql.com/doc/refman/5.1/en/commit.html%5B/URL%5D)

---

<div class="post-metadata">

**Author:** ![moazam](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@moazam](https://forums.percona.com/u/moazam)\
**Post date:** [August 12, 2009, 5:18am UTC](https://forums.percona.com/t/innodb-transaction-problem/1235/3 "2009-08-12T05:18:23Z")

</div>

sorry about that typo, its mysql\_query, there is no code error. As far as I know commit should work with begin or start transaction.
