Issue updating database from csv file

Hi,

I have an action that uploads a csv file of users to the website.
(Uploads fine)

The code loops through each row checking if the user already exists and
then either updating the attributes or adding a new user to the
database.

The csv file has over 3000 rows and does not complete.
(At one point I got an error:
A ActiveRecord::Transactions::TransactionError occurred in
pupils#upload:

Transaction aborted
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactions.rb:84:in
`transaction’
)

I have tried with smaller csv files, 1000 lines, and some times it works
and others it fails.

The code uses the CSV.open and each to loop through the rows.

Has anyone had an issue like this or know what is happening?

Thanks

Alan