From 00542c30c22fea734f5e7bffc5d195b016f432a0 Mon Sep 17 00:00:00 2001 From: Umberto D'Ovidio Date: Fri, 14 Oct 2022 11:20:07 +0200 Subject: [PATCH 1/2] send 503 for requests executed during a backup --- .../resources/i18n/translations_de.properties | 1 + .../resources/i18n/translations_en.properties | 1 + .../mesh/graphdb/OrientDBDatabase.java | 3 +++ .../rest/error/AbstractRestException.java | 2 +- .../rest/error/BackupInProgressException.java | 20 +++++++++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 rest-model/src/main/java/com/gentics/mesh/core/rest/error/BackupInProgressException.java diff --git a/common/src/main/resources/i18n/translations_de.properties b/common/src/main/resources/i18n/translations_de.properties index 14b99a3045..db80874f1f 100644 --- a/common/src/main/resources/i18n/translations_de.properties +++ b/common/src/main/resources/i18n/translations_de.properties @@ -243,6 +243,7 @@ import_failed=Import fehlgeschlagen. backup_finished=Backup abgeschlossen. backup_failed=Backup fehlgeschlagen. +backup_in_progress=Zugriff auf Datenbank nicht möglich, Backup läuft. backup_consistency_check_failed=Backup fehlgeschlagen. Der Konsistenzcheck hat {0} Inkonsistenzen gefunden. backup_error_not_supported_in_memory_mode=Backup Operationen können nicht durchgeführt werden wenn der in-memory modus verwendet wird. diff --git a/common/src/main/resources/i18n/translations_en.properties b/common/src/main/resources/i18n/translations_en.properties index 9963bdd56b..4069f00976 100644 --- a/common/src/main/resources/i18n/translations_en.properties +++ b/common/src/main/resources/i18n/translations_en.properties @@ -242,6 +242,7 @@ import_failed=Import failed. backup_finished=Backup completed. backup_failed=Backup failed. +backup_in_progress=Cannot access database, backup is in progress. backup_consistency_check_failed=Backup failed. Consistency check found {0} inconsistencies. backup_error_not_supported_in_memory_mode=Backup operation can not be run in memory mode. diff --git a/databases/orientdb/src/main/java/com/gentics/mesh/graphdb/OrientDBDatabase.java b/databases/orientdb/src/main/java/com/gentics/mesh/graphdb/OrientDBDatabase.java index 3eeb4f0ac6..f18a8b387e 100644 --- a/databases/orientdb/src/main/java/com/gentics/mesh/graphdb/OrientDBDatabase.java +++ b/databases/orientdb/src/main/java/com/gentics/mesh/graphdb/OrientDBDatabase.java @@ -27,6 +27,7 @@ import javax.inject.Inject; import javax.inject.Singleton; +import com.gentics.mesh.core.rest.error.BackupInProgressException; import org.apache.commons.lang3.tuple.Triple; import com.gentics.madl.tx.Tx; @@ -561,6 +562,8 @@ private void checkStatus() { case READY: case STARTING: return; + case BACKUP: + throw new BackupInProgressException(); default: throw new RuntimeException("Mesh is not ready. Current status " + status.name() + ". Aborting transaction."); } diff --git a/rest-model/src/main/java/com/gentics/mesh/core/rest/error/AbstractRestException.java b/rest-model/src/main/java/com/gentics/mesh/core/rest/error/AbstractRestException.java index 8826139668..18205d4621 100644 --- a/rest-model/src/main/java/com/gentics/mesh/core/rest/error/AbstractRestException.java +++ b/rest-model/src/main/java/com/gentics/mesh/core/rest/error/AbstractRestException.java @@ -11,7 +11,7 @@ /** * Abstract class for regular rest exceptions. This class should be used when returning the exception information via a JSON response. */ -@JsonIgnoreProperties({ "suppressed", "cause", "detailMessage", "stackTrace", "localizedMessage" }) +@JsonIgnoreProperties({ "suppressed", "cause", "detailMessage", "stackTrace", "localizedMessage", "logStackTrace" }) public abstract class AbstractRestException extends RuntimeException { private static final long serialVersionUID = 2209919403583173663L; diff --git a/rest-model/src/main/java/com/gentics/mesh/core/rest/error/BackupInProgressException.java b/rest-model/src/main/java/com/gentics/mesh/core/rest/error/BackupInProgressException.java new file mode 100644 index 0000000000..1d4f575576 --- /dev/null +++ b/rest-model/src/main/java/com/gentics/mesh/core/rest/error/BackupInProgressException.java @@ -0,0 +1,20 @@ +package com.gentics.mesh.core.rest.error; + +import io.netty.handler.codec.http.HttpResponseStatus; + +/** + * This exception should be thrown when the database is not available due to a backup. + */ +public class BackupInProgressException extends AbstractRestException { + + private static final String TYPE = "backup_in_progress"; + + public BackupInProgressException() { + super(HttpResponseStatus.SERVICE_UNAVAILABLE, "backup_in_progress"); + } + + @Override + public String getType() { + return TYPE; + } +} From 287c1ccb42aa4d3caf69c0b392569ef014ecf795 Mon Sep 17 00:00:00 2001 From: Umberto D'Ovidio Date: Fri, 14 Oct 2022 11:20:36 +0200 Subject: [PATCH 2/2] update changelog --- LTS-CHANGELOG.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LTS-CHANGELOG.adoc b/LTS-CHANGELOG.adoc index 90358eb686..f426dc0f4e 100644 --- a/LTS-CHANGELOG.adoc +++ b/LTS-CHANGELOG.adoc @@ -17,6 +17,11 @@ include::content/docs/variables.adoc-include[] The LTS changelog lists releases which are only accessible via a commercial subscription. All fixes and changes in LTS releases will be released the next minor release. Changes from LTS 1.4.x will be included in release 1.5.0. +[[v1.6.36]] +== 1.6.36 (TBD) + +icon:check[] OrientDB: previously when a backup was in progress all requests would fail with a 500 status code as an internal error. This has been changed to send a 503 status code with a descriptive message. + [[v1.6.35]] == 1.6.35 (06.10.2022)