Repository navigation
Description
Affected module
Backend
Describe the bug
PUT /api/v1/dataQuality/testSuites (createOrUpdateLogicalTestSuite) on an existing logical test suite records every test case of the suite as removed from tests, although the test cases stay in the suite.
CreateTestSuite has no tests property, so the entity built from the request always has tests empty. TestSuiteUpdater.entitySpecificUpdate then compares the stored test list with the empty one and calls recordChange("tests", origTests, []). Nothing removes the relationships, so the suite keeps its test cases, but the version history says they were all deleted.
The whole list of test case references is written into the suite's changeDescription / incrementalChangeDescription (stored in the entity JSON) and into the change event, on every PUT. With a large logical suite this is several MB per call. A client that calls create_or_update for its logical suite on every run (for example to keep the description in sync) produces a new full-list "removal" each time.
To Reproduce
- Create a logical test suite and add a few test cases to it (
PUT /api/v1/dataQuality/testCases/logicalTestCases). - Send the same create request again:
PUT /api/v1/dataQuality/testSuiteswith{"name": "<suite>", "description": "..."}(no change, or only a description change). The Python SDK'smetadata.create_or_update(CreateTestSuiteRequest(...))sends this request. GET /api/v1/dataQuality/testSuites/{id}?fields=tests: all test cases are still listed.GET /api/v1/dataQuality/testSuites/{id}/versions/{version}(or the response of step 2):changeDescription.fieldsDeletedcontainstestswith every test case reference, andversionwas bumped.
Expected behavior
A PUT whose request cannot carry tests should leave tests out of the comparison, as a PATCH that does not touch tests does. No change should be recorded for tests and, if nothing else changed, the version should not change.
OS
N/A (server behavior, not OS-specific)
Python version
N/A (the server is affected; the SDK only sends the request)
OpenMetadata version
2.0.1 (observed). By reading the code, the same behavior is expected on 2.0.10 and main (6c23808).
OpenMetadata Ingestion package version
2.0.1
Additional context
Where it happens (from reading the code)
- The PUT builds the suite from
CreateTestSuite, which has notestsproperty:Lines 710 to 739 in 6c23808
@PUT @Operation( operationId = "createOrUpdateLogicalTestSuite", summary = "Update logical test suite", description = "Create a logical TestSuite, if it does not exist or update an existing test suite.", responses = { @ApiResponse( responseCode = "200", description = "The updated test definition ", content = @Content( mediaType = "application/json", schema = @Schema(implementation = TestSuite.class))) }) public Response createOrUpdate( @Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateTestSuite create) { create = create.withBasicEntityReference( null); // entity reference is not applicable for logical test suites TestSuite testSuite = mapper.createToEntity(create, securityContext.getUserPrincipal().getName()); testSuite.setBasic(false); List<AuthRequest> authRequests = new java.util.ArrayList<>( getAuthRequestsForUpdate(testSuite, ResourceContextInterface.Operation.PUT, null)); authRequests.addAll(getAuthRequestsForPost(testSuite)); return createOrUpdate( - https://github.com/open-metadata/OpenMetadata/blob/6c23808e89be7defa8701d8ba0f760f23480f435/openmetadata-spec/src/main/resources/json/schema/api/tests/createTestSuite.json
- The updater compares the stored list with the empty one:
- 2.0.10: https://github.com/open-metadata/OpenMetadata/blob/2.0.10-release/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java#L1125-L1132
- main:
Lines 1157 to 1164 in 6c23808
public void entitySpecificUpdate(boolean consolidatingChanges) { compareAndUpdate( UPDATE_FIELDS, () -> { List<EntityReference> origTests = listOrEmpty(original.getTests()); List<EntityReference> updatedTests = listOrEmpty(updated.getTests()); recordChange(UPDATE_FIELDS, origTests, updatedTests); });
preparedoes nothing, so nothing carries the storedtestsover to the updated entity before the comparison.
How we noticed
On 2.0.1 a job called create_or_update for a logical suite of every service on each run. The stored incrementalChangeDescription of one suite reached about 5 MB, all of it the list of removed tests. Together with a second issue (the testSuites field of a test case embeds this incrementalChangeDescription, reported in #38799), every test case result write stored hundreds of KB in change_event, successful_sent_change_events, audit_log_event and entity_extension, and the database grew by about 160 GB in about 20 hours. After we stopped calling PUT on the logical suites, the rows went back to about 6 KB.
Possible fix
In TestSuiteUpdater, compare tests only when the request carries it (for example skip it for Operation.PUT, or copy original.getTests() to updated before the comparison when updated.getTests() is null). Test case membership of a logical suite is managed through /testCases/logicalTestCases anyway.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity