[OPEN-ILS-DEV] clarification about commits and rollbacks in action.pm

Steven Chan schan at vcn.bc.ca
Thu Apr 9 15:19:08 EDT 2009


I'm puzzled about the sequence of commits and rollbacks in the Perl 
module Storage::Publisher::action.pm in the open-ils software.
Most of the transactions in action.pm are structured in this way:

try {
     do_things_including_some_db_operations();
     $self->method_lookup('open-ils.storage.transaction.commit')->run;
     do_more_things_including_more_db_operations();
} otherwise {
     log_errors();
     $self->method_lookup('open-ils.storage.transaction.rollback')->run;
};

That is, an often lengthy sequence of Perl code is done inside a try block with a database commit,
followed by an otherwise block where a rollback is done.
But is it not possible for there to be errors
(for example, run-time errors from bad Perl syntax or file I/O access errors)
leading to the commit and yet for the commit to succeed?
If so, then wouldn't the rollback be too late to rollback any database
operations before and including the commit?
Would it not be safer to do the commit outside the try block?

-- 
Steven Chan
BC Evergreen project


More information about the Open-ils-dev mailing list