← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/maas/distclean-race into lp:maas

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/distclean-race into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jtv/maas/distclean-race/+merge/95153

There's a tiny race condition in the shell script that cleans up the local database cluster in a branch.  The database writes back its statistics, and this can apparently cause its stats directory to become nonempty just between the time “rm -rf” scans it (finding it empty and ready for deletion) and the actual attempt to delete the directory.  Or something along those lines.  Surprisingly, it happens pretty often.  It can break build attempts if a previous “make distclean” left the cluster destroyed but the nonempty directory in place.

This patch fixes that by repeating the deletion attempt until it succeeds.  It doesn't deal with the case where the “rm -rf” fails for persistent reasons (so it just keeps looping); but there should be error output and you'll just have to hit ctrl-C to kill the script.  If that ever becomes an issue, we'll worry about it then.
-- 
https://code.launchpad.net/~jtv/maas/distclean-race/+merge/95153
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/distclean-race into lp:maas.
=== modified file 'utilities/maasdb'
--- utilities/maasdb	2012-02-16 11:31:00 +0000
+++ utilities/maasdb	2012-02-29 11:21:24 +0000
@@ -145,7 +145,15 @@
     if test -d "$DATADIR/base"
     then
         maasdb_stop_cluster "$DATADIR"
-        rm -rf -- "$DATADIR"
+        # Removing the data directory may fail because of a race condition
+        # where db/global is nonempty because of a statistics write.  Rather
+        # than block on shutdown, be optimistic and spin on retries.
+        while ! rm -rf -- "$DATADIR"
+        do
+            # If this fails for a more persistent reason, too bad.  Ctrl-C.
+            echo "Retrying deletion of $DATADIR." >&2
+            sleep 0.01
+        done
     fi
 }