From 89f6bb0cc6b435c7e7e8ae631766e081a173a0c4 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Thu, 18 Dec 2014 10:25:23 +0100 Subject: [PATCH] Handle concurrent deletion while fetching all documents --- src/jio.storage/querystorage.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/jio.storage/querystorage.js b/src/jio.storage/querystorage.js index e46e9b2..09b61de 100644 --- a/src/jio.storage/querystorage.js +++ b/src/jio.storage/querystorage.js @@ -101,12 +101,22 @@ var include_query_list = [result], len, i; + + function safeGet(j) { + return substorage.get({"_id": result[j].id}) + .push(undefined, function (error) { + // Document may have been dropped after listing + if ((error instanceof jIO.util.jIOError) && (error.status_code === 404)) { + return; + } + throw error; + }); + } + if (is_manual_include_needed) { len = result.length; for (i = 0; i < len; i += 1) { - include_query_list.push( - substorage.get({"_id": result[i].id}) - ); + include_query_list.push(safeGet(i)); } result = RSVP.all(include_query_list); } -- 2.30.9