Purge (micro)schema versions - #1753
Conversation
| @@ -1,140 +0,0 @@ | |||
| package com.gentics.mesh.core.project.maintenance; | |||
There was a problem hiding this comment.
Completely unused. The correct implementation of ProjectVersionPurgeHandler is loaded elsewhere.
| // truncate the error detail message to the max length for the error detail property | ||
| setErrorDetail(truncateStackTrace(stackTrace)); | ||
| setErrorMessage(e.getMessage()); | ||
| setErrorMessage(StringUtils.substring(e.getMessage(), 0, 255)); |
| } | ||
| if (version.getPreviousVersion() != null) { | ||
| version.getPreviousVersion().setNextVersion(null); | ||
| version.getPreviousVersion().setNextVersion(version.getNextVersion()); |
There was a problem hiding this comment.
Bug in version removal. Worth porting to hotfix.
| if (status != null) { | ||
| boolean allMatching = true; | ||
| for (JobResponse info : response.getData()) { | ||
| if (before.getData().stream().anyMatch(j -> Objects.equal(j.getUuid(), info.getUuid()))) { |
There was a problem hiding this comment.
We count only new jobs.
|
|
||
| @Parameters(name = "{index}: {0}") | ||
| public static Collection<Object[]> parameters() { | ||
| return List.of(new Object[] { 0 }, new Object[] { 1 }, new Object[] { 2 }, new Object[] { 5 }, new Object[] { 8 }); |
There was a problem hiding this comment.
Random meaningful numbers, including 1 (nothing to clean) and 0 (no changes).
| } | ||
|
|
||
| @Test | ||
| @Category({FailingTests.class}) |
There was a problem hiding this comment.
Not anymore failing.
Updated the changelog entry to specify that the purge process saves storage resources.
…terized requests.
Updated the purge process for schemas and microschemas to use new REST API endpoints, allowing for parameterization by schema name/UUID filters.
| @@ -0,0 +1,2 @@ | |||
| Core: Now it is possible to purge empty (micro)schema versions automatically, via new background jobs. This will save storage and runtime resources of the database. | |||
| The purge process is triggered via REST API `POST /utilities/purge/schemas/versions` and `POST /utilities/purge/microschemas/versions` respectively, and can be parameterized by schema name/UUID filters. | |||
There was a problem hiding this comment.
The calls have to be moved to /utilities because of POST /schemas/{uuid} taking over the /schemas/purge calls
| endpoint.exampleRequest(microschemaExamples.getGeolocationMicroschemaCreateRequest()); | ||
| endpoint.exampleResponse(OK, utilityExamples.createValidationResponse(), "The validation report"); | ||
| endpoint.blockingHandler(rc -> { | ||
| private void addValidationHandler() { |
| /** | ||
| * Set the job start query. | ||
| */ | ||
| void setQuery(String query); |
There was a problem hiding this comment.
General purpose job query.
| purgeSchemaVersionsEndpoint.method(POST); | ||
| purgeSchemaVersionsEndpoint.description("Purge the unused schema versions."); | ||
| purgeSchemaVersionsEndpoint.consumes(APPLICATION_JSON); | ||
| purgeSchemaVersionsEndpoint.exampleRequest(miscExamples.createNameOrUuidsRequest()); |
There was a problem hiding this comment.
I favored a POST body over query parameters request, as it can hold more values, if required. Matter of a discussion though.
|
|
||
| @Override | ||
| public void beforeVersionDeletedFromDatabase(HibMicroschemaVersion version) { | ||
| HibernateTx tx = HibernateTx.get(); |
There was a problem hiding this comment.
It really looks to me that no one had ever tested the deletion of microschema versions until this moment.
Abstract
To same database time/space, we could delete empty versions.
Checklist
General
/CHANGELOG.adocOn API Changes