# Rails transaction rollback failed

**URL:** <https://www.ruby-forum.com/t/rails-transaction-rollback-failed/72993>\
**Category:** Rails\
**Created:** [October 20, 2006, 1:14pm UTC](https://www.ruby-forum.com/t/rails-transaction-rollback-failed/72993 "2006-10-20T13:14:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincentcao](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/977dab/32.png) [@vincentcao](https://www.ruby-forum.com/u/vincentcao)\
**Post date:** [October 20, 2006, 1:14pm UTC](https://www.ruby-forum.com/t/rails-transaction-rollback-failed/72993/1 "2006-10-20T13:14:16Z")

</div>

i use rails transaction like these:

Account.transaction do  
first.do\_something  
end

in first.do\_something, i set a error, it should be rollback after these  
code excuted  
here is a param in my log:

e[4;36;1mSQL (0.000000)e[0m e[0;1mROLLBACKe[0m

i find rails do rollback operation, but in my database ,the data is not  
rollback,  
anybody may help?

---

<div class="post-metadata">

**Author:** ![vincentcao](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/977dab/32.png) [@vincentcao](https://www.ruby-forum.com/u/vincentcao)\
**Post date:** [October 20, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/rails-transaction-rollback-failed/72993/2 "2006-10-20T14:44:04Z")

</div>

I _think_ this is the deal: the default table type in MySQL is MyISAM,  
which is generally good for speed with web apps and such, but it does  
not support transactions. So MySQL will take the rollback command, but  
won’t actually roll anything back.

To enable transactions, you must be working with an InnoDB table, which  
is the more hardcore table type in MySQL. It requires more resources to  
read and write these tables, but according to [databasejournal.com](http://databasejournal.com), you  
get these benefits:

```
  InnoDB Features

* ACID-compliant transactions.
* Full referential integrity
* Row-level locking
* Tables are stored in a tablespace (unlike MyISAM tables where each
  table is a file)

```

Jason

---

<div class="post-metadata">

**Author:** ![vincentcao](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/977dab/32.png) [@vincentcao](https://www.ruby-forum.com/u/vincentcao)\
**Post date:** [October 21, 2006, 9:54am UTC](https://www.ruby-forum.com/t/rails-transaction-rollback-failed/72993/3 "2006-10-21T09:54:48Z")

</div>

I try your suggestion ,set my table type as InnoDB, but still not  
rollback.  
there is something like config i miss?
