diff --git a/lib/fluent-query/connection.rb b/lib/fluent-query/connection.rb
index <HASH>..<HASH> 100755
--- a/lib/fluent-query/connection.rb
+++ b/lib/fluent-query/connection.rb
@@ -256,7 +256,12 @@ module FluentQuery
         public

         def transaction(&block)

             self.begin

-            block.call

+            begin

+                block.call

+            rescue ::Exception => e

+                self.rollback

+                raise e

+            end

             self.commit

         end
bug: transactions must correctly rollback in case of exception