From ce8d203235b02d8570349938655bac42377755bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 3 May 2023 10:49:49 +0200 Subject: [PATCH] Ensure that entity cache state is only written to the database when actually changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/chilled-queens-wonder.md | 5 +++++ .../src/processing/DefaultCatalogProcessingEngine.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/chilled-queens-wonder.md diff --git a/.changeset/chilled-queens-wonder.md b/.changeset/chilled-queens-wonder.md new file mode 100644 index 0000000000..a10212792d --- /dev/null +++ b/.changeset/chilled-queens-wonder.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Ensure that entity cache state is only written to the database when actually changed diff --git a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts index ab1e0b96c9..e89d53f79f 100644 --- a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts +++ b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts @@ -150,7 +150,10 @@ export class DefaultCatalogProcessingEngine implements CatalogProcessingEngine { track.markProcessorsCompleted(result); if (result.ok) { - if (stableStringify(state) !== stableStringify(result.state)) { + const { ttl: _, ...stateWithoutTtl } = state ?? {}; + if ( + stableStringify(stateWithoutTtl) !== stableStringify(result.state) + ) { await this.processingDatabase.transaction(async tx => { await this.processingDatabase.updateEntityCache(tx, { id,