Index: trunk/Nebulous-Server/lib/Nebulous/Server.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 23348)
+++ trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 23455)
@@ -269,24 +269,30 @@
     $newkey = parse_neb_key($newkey);
 
-    eval {
-        # rename storage_object
-        my $query = $db->prepare_cached($sql->rename_object); 
-        # this SQL statment takes the new key name as the first param
-        my $rows = $query->execute($newkey->path, $key->path);
-
-        # if we affected more then one row something very bad has happened.
-        unless ($rows == 1) {
-            $query->finish;
-            $log->logdie("affected row count is $rows instead of 1");
-        }
-
-        $db->commit;
-        $log->debug("commit");
-    };
-    if ($@) {
-        $db->rollback;
-        $log->debug("rollback");
-        $log->logdie("database error: $@");
-    }
+    TRANS: do {
+        eval {
+            # rename storage_object
+            my $query = $db->prepare_cached($sql->rename_object); 
+            # this SQL statment takes the new key name as the first param
+            my $rows = $query->execute($newkey->path, $key->path);
+
+            # if we affected more then one row something very bad has happened.
+            unless ($rows == 1) {
+                $query->finish;
+                $log->logdie("affected row count is $rows instead of 1");
+            }
+
+            $db->commit;
+            $log->debug("commit");
+        };
+        if ($@) {
+            $db->rollback;
+            $log->debug("rollback");
+            if ($@ =~ /Deadlock found/) {
+                $log->warn("database deadlock retrying transaction: $@");
+                redo;
+            }
+            $log->logdie("database error: $@");
+        }
+    } while $@;
 
     $log->debug("leaving");
