Hello,
I'm having trouble with transactions with rails 3.0.3 and mysql 5. I'd
like to import data etl-batch-style:
class Job < ActiveRecord::Base
# ...
def perform_etl
connection.transaction do
extract # some connection.execute / job.update_attribute stuff
transform # some connection.execute / job.update_attribute stuff
end
end
#...
end
I'm using InnoDB as storage engine and transaction seem to be working
so far: If I start a job while being logged in before starting that
job, my session is isolated and I don't see any data.
But: If the job fails (exeption) there is data in the database -
although a rollback is performed:
The rollback itself is logged "SQL (0.1ms) ROLLBACK" - and no COMMIT
is logged.
Is rails perfoming a "ROLLBACKUP TO SAVEPOINT" instead?
How can I make sure, that no data is written, if a ROLLBACK happens?
Thanks,
yanosz
Hello,
I'm having trouble with transactions with rails 3.0.3 and mysql 5. I'd
like to import data etl-batch-style:
class Job < ActiveRecord::Base
# ...
def perform_etl
connection.transaction do
extract # some connection.execute / job.update_attribute stuff
transform # some connection.execute / job.update_attribute stuff
end
end
#...
end
I'm using InnoDB as storage engine and transaction seem to be working
so far: If I start a job while being logged in before starting that
job, my session is isolated and I don't see any data.
But: If the job fails (exeption) there is data in the database -
although a rollback is performed:
The rollback itself is logged "SQL (0.1ms) ROLLBACK" - and no COMMIT
is logged.
Is rails perfoming a "ROLLBACKUP TO SAVEPOINT" instead?
How can I make sure, that no data is written, if a ROLLBACK happens?
Well if the log says rollback then that should be what was executed. Is any non transaction safe stuff happening (eg calling begin, altering tables etc) ?
Fred