diff --git a/lib/mosql/streamer.rb b/lib/mosql/streamer.rb index d630e96..95ed2c6 100644 --- a/lib/mosql/streamer.rb +++ b/lib/mosql/streamer.rb @@ -141,21 +141,19 @@ def import_collection(ns, collection, filter) start = Time.now sql_time = 0 - collection.find(filter, :batch_size => BATCH) do |cursor| - with_retries do - cursor.each do |obj| - batch << @schema.transform(ns, obj) - count += 1 - - if batch.length >= BATCH - sql_time += track_time do - bulk_upsert(table, ns, batch) - end - elapsed = Time.now - start - log.info("Imported #{count} rows (#{elapsed}s, #{sql_time}s SQL)...") - batch.clear - exit(0) if @done + collection.find(filter, :timeout => false, :batch_size => BATCH) do |cursor| + cursor.each do |obj| + batch << @schema.transform(ns, obj) + count += 1 + + if batch.length >= BATCH + sql_time += track_time do + bulk_upsert(table, ns, batch) end + elapsed = Time.now - start + log.info("Imported #{count} rows (#{elapsed}s, #{sql_time}s SQL)...") + batch.clear + exit(0) if @done end end end