From 2519f4b20d2c66777eca6158fa2f6731155facdc Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Mon, 5 Dec 2022 12:09:30 +0100 Subject: [PATCH] Disabled autoRefresh for batch sending service to increase performance fixes https://github.com/TryGhost/Team/issues/2363 --- ghost/email-service/lib/batch-sending-service.js | 14 +++++++------- ghost/email-service/lib/email-event-storage.js | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ghost/email-service/lib/batch-sending-service.js b/ghost/email-service/lib/batch-sending-service.js index 0eefe0dedd..5ef06afce9 100644 --- a/ghost/email-service/lib/batch-sending-service.js +++ b/ghost/email-service/lib/batch-sending-service.js @@ -93,7 +93,7 @@ class BatchSendingService { status: 'submitted', submitted_at: new Date(), error: null - }, {patch: true}); + }, {patch: true, autoRefresh: false}); } catch (e) { logging.error(`Error sending email ${email.id}: ${e.message}`); @@ -101,7 +101,7 @@ class BatchSendingService { await email.save({ status: 'failed', error: e.message || 'Something went wrong while sending the email' - }, {patch: true}); + }, {patch: true, autoRefresh: false}); } } @@ -188,7 +188,7 @@ class BatchSendingService { // between creating the email and sending it (or when the email failed initially and is retried a day later) await email.save({ email_count: totalCount - }, {patch: true, require: false}); + }, {patch: true, require: false, autoRefresh: false}); } return batches; } @@ -316,7 +316,7 @@ class BatchSendingService { error_status_code: null, error_message: null, error_data: null - }, {patch: true, require: false}); + }, {patch: true, require: false, autoRefresh: false}); succeeded = true; } catch (err) { logging.error(`Error sending email batch ${batch.id}`); @@ -327,13 +327,13 @@ class BatchSendingService { error_status_code: err.statusCode, error_message: err.message, error_data: err.errorDetails - }, {patch: true, require: false}); + }, {patch: true, require: false, autoRefresh: false}); } // Mark as processed, even when failed await this.#models.EmailRecipient .where({batch_id: batch.id}) - .save({processed_at: new Date()}, {patch: true, require: false}); + .save({processed_at: new Date()}, {patch: true, require: false, autoRefresh: false}); return succeeded; } @@ -375,7 +375,7 @@ class BatchSendingService { } await model.save({ status - }, {patch: true, transacting}); + }, {patch: true, transacting, autoRefresh: false}); }); return model; } diff --git a/ghost/email-service/lib/email-event-storage.js b/ghost/email-service/lib/email-event-storage.js index 9ea850b547..49b6855838 100644 --- a/ghost/email-service/lib/email-event-storage.js +++ b/ghost/email-service/lib/email-event-storage.js @@ -156,7 +156,7 @@ class EmailEventStorage { enhanced_code: event.error.enhancedCode ?? null, failed_at: event.timestamp, event_id: event.id - }, {...options, patch: true}); + }, {...options, patch: true, autoRefresh: false}); } }