Adds sanity check on number of collections retrieved
authorJoshua C. Randall <jcrandall@alum.mit.edu>
Thu, 18 Feb 2016 00:02:06 +0000 (00:02 +0000)
committerJoshua C. Randall <jcrandall@alum.mit.edu>
Thu, 18 Feb 2016 00:02:06 +0000 (00:02 +0000)
Changes GetCollections() to return an error if the number
of collections retrieved is less than the initial number
of collections.

services/datamanager/collection/collection.go

index 1229f2917e21f9b17d897db8fe85e7adb4e43429..724e3ec5dbfb0897c3689c0588546092372c9134 100644 (file)
@@ -227,6 +227,17 @@ func GetCollections(params GetCollectionsParams) (results ReadCollections, err e
                }
        }
 
+       if totalCollections < initialNumberOfCollectionsAvailable {
+               err = fmt.Errorf("Initially there were %d collections available, "+
+                               "but we only retrieved %d. Refusing to continue as "+
+                               "this could indicate an otherwise undetected "+
+                               "failure, though it is also possible that "+
+                               "collections were deleted by another process "+
+                               "while datamanager was running.",
+                               initialNumberOfCollectionsAvailable, totalCollections)
+               return
+       }
+
        // Write the heap profile for examining memory usage
        err = WriteHeapProfile()