MB-20247: Check scan return code 01/68801/2
authorJim Walker <jim@couchbase.com>
Mon, 17 Oct 2016 10:21:40 +0000 (11:21 +0100)
committerDave Rigby <daver@couchbase.com>
Tue, 18 Oct 2016 12:19:57 +0000 (12:19 +0000)
kvstore->scan can fail, so check the return code to prevent trying
to continue loading whilst failing.

Extension of changes made for MB-16910

Change-Id: Ia890d685d7acb144eca374ca0964e3d65100f89e
Reviewed-on: http://review.couchbase.org/68801
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
src/warmup.cc

index 456039a..ede15c1 100644 (file)
@@ -583,8 +583,12 @@ void Warmup::keyDumpforShard(uint16_t shardId)
                                                     DocumentFilter::NO_DELETES,
                                                     ValueFilter::KEYS_ONLY);
         if (ctx) {
-            kvstore->scan(ctx);
+            auto errorCode = kvstore->scan(ctx);
             kvstore->destroyScanContext(ctx);
+            if (errorCode == scan_again) { // ENGINE_ENOMEM
+                // skip loading remaining VBuckets as memory limit was reached
+                break;
+            }
         }
     }