From 7142c7c113edbe8819d27861c064b59c66f393cf Mon Sep 17 00:00:00 2001 From: mlimaloureiro Date: Mon, 24 Apr 2017 11:39:47 +0100 Subject: [PATCH 1/2] Increase write capacity when using overwrite --- lib/dynamo-restore.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/dynamo-restore.js b/lib/dynamo-restore.js index b341fb8..06d0927 100755 --- a/lib/dynamo-restore.js +++ b/lib/dynamo-restore.js @@ -106,6 +106,18 @@ DynamoRestore.prototype._checkTableExists = function(error, data) { // Table exists, should we overwrite it?? if (this.options.overwrite) { this.emit('warning', util.format('WARN: table [%s] will be overwritten.', this.options.table)); + params = { + TableName: this.options.table, + ProvisionedThroughput: { + ReadCapacityUnits: this.options.readcapacity || 10, + WriteCapacityUnits: this.options.concurrency + } + }; + dynamodb.updateTable(params, (function(error, data) { + if (error || !data) { + return this.emit('error', 'Fatal Error. Failed to update table. ' + error); + } + }).bind(this)); setTimeout(dynamodb.describeTable.bind(dynamodb, { TableName: this.options.table }, this._checkTableReady.bind(this)), 1000); } else { this.emit('error', 'Fatal Error. The destination table already exists! Exiting process..'); From 08a773f288cc09da5be0592e8075c3383854e0f3 Mon Sep 17 00:00:00 2001 From: mlimaloureiro Date: Mon, 24 Apr 2017 11:40:02 +0100 Subject: [PATCH 2/2] Show error message --- lib/dynamo-restore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dynamo-restore.js b/lib/dynamo-restore.js index 06d0927..1bff915 100755 --- a/lib/dynamo-restore.js +++ b/lib/dynamo-restore.js @@ -109,7 +109,7 @@ DynamoRestore.prototype._checkTableExists = function(error, data) { params = { TableName: this.options.table, ProvisionedThroughput: { - ReadCapacityUnits: this.options.readcapacity || 10, + ReadCapacityUnits: this.options.readcapacity, WriteCapacityUnits: this.options.concurrency } }; @@ -319,7 +319,7 @@ DynamoRestore.prototype._sendBatch = function() { this.emit('warning', 'Failed to upload same batch too many times, removing from queue.. \n' + JSON.stringify(batch)); } } else { - this.emit('warning', 'Error processing batch, putting back in the queue.'); + this.emit('warning', 'Error processing batch, putting back in the queue: ' + error); batch.attempts++; this.batches.push(batch); }