IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23455


Ignore:
Timestamp:
Mar 20, 2009, 10:23:10 AM (17 years ago)
Author:
jhoblitt
Message:

retry db transactions in Nebulous::Server::rename_object()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r20990 r23455  
    269269    $newkey = parse_neb_key($newkey);
    270270
    271     eval {
    272         # rename storage_object
    273         my $query = $db->prepare_cached($sql->rename_object);
    274         # this SQL statment takes the new key name as the first param
    275         my $rows = $query->execute($newkey->path, $key->path);
    276 
    277         # if we affected more then one row something very bad has happened.
    278         unless ($rows == 1) {
    279             $query->finish;
    280             $log->logdie("affected row count is $rows instead of 1");
    281         }
    282 
    283         $db->commit;
    284         $log->debug("commit");
    285     };
    286     if ($@) {
    287         $db->rollback;
    288         $log->debug("rollback");
    289         $log->logdie("database error: $@");
    290     }
     271    TRANS: do {
     272        eval {
     273            # rename storage_object
     274            my $query = $db->prepare_cached($sql->rename_object);
     275            # this SQL statment takes the new key name as the first param
     276            my $rows = $query->execute($newkey->path, $key->path);
     277
     278            # if we affected more then one row something very bad has happened.
     279            unless ($rows == 1) {
     280                $query->finish;
     281                $log->logdie("affected row count is $rows instead of 1");
     282            }
     283
     284            $db->commit;
     285            $log->debug("commit");
     286        };
     287        if ($@) {
     288            $db->rollback;
     289            $log->debug("rollback");
     290            if ($@ =~ /Deadlock found/) {
     291                $log->warn("database deadlock retrying transaction: $@");
     292                redo;
     293            }
     294            $log->logdie("database error: $@");
     295        }
     296    } while $@;
    291297
    292298    $log->debug("leaving");
Note: See TracChangeset for help on using the changeset viewer.