Repository navigation
Conversation
Per the Java guide (no fully-qualified names in executable code), import BulkAssets, Relationship, ChangeActor, BulkOperationResult, and Transaction in DataProductRepositoryTransactionTest, and import Relationship in DataProductPortsAtomicityIT. Addresses review feedback.
…-bulk-ports-writes-in-04586d
The three cases only reflect on @transaction annotations; two of them pass on main without the fix, and none would catch a regression that removed the executeInTransaction boundary. DataProductPortsAtomicityIT is the behavioural regression: both of its cases fail on main (partial port rows visible while the bulk add/remove is blocked) and pass with the fix.
|
Verified locally (MySQL + Elasticsearch, global-state lane):
|
yan-3005
left a comment
There was a problem hiding this comment.
Verified: DataProductPortsAtomicityIT fails 2/2 on main (partial port rows visible mid-flow) and passes 2/2 with this fix; deadlock retry replays cleanly through DeferralScope. LGTM.
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
…on (#38392) (#38515) * Fixes #38355: wrap Data Product bulk ports writes in a real transaction * Use imports instead of fully-qualified names in new tests Per the Java guide (no fully-qualified names in executable code), import BulkAssets, Relationship, ChangeActor, BulkOperationResult, and Transaction in DataProductRepositoryTransactionTest, and import Relationship in DataProductPortsAtomicityIT. Addresses review feedback. * Drop annotation-only DataProductRepositoryTransactionTest The three cases only reflect on @transaction annotations; two of them pass on main without the fix, and none would catch a regression that removed the executeInTransaction boundary. DataProductPortsAtomicityIT is the behavioural regression: both of its cases fail on main (partial port rows visible while the bulk add/remove is blocked) and pass with the fix. --------- (cherry picked from commit 146d6ed) Co-authored-by: detail-app[bot] <180357370+detail-app[bot]@users.noreply.github.com> Co-authored-by: Ram Narayan Balaji <[email protected]> Co-authored-by: Ram Narayan Balaji <[email protected]>
Detail bug report: View on Detail
Describe your changes:
Fixes #38355
I worked on the Data Product bulk input/output port APIs (
PUT /v1/dataProducts/{id|name}/{inputPorts|outputPorts}/{add|remove}) because a mid-flow failure could partially commit the batch. The privatebulkPortsOperationcarried@Transaction, but repositories are plain classes instantiated via reflection — not JDBI SQL-object proxies — so the annotation is inert. With no caller opening a real transaction, each on-demand DAO call in the write path (addRelationship/deleteRelationshipper port,changeEventDAO().insert,storeEntity) grabbed its own connection and auto-committed. A failure on statement N+1 left the first N port relationship rows permanently persisted while the client received a 5xx with no per-row accounting — divergent port/entity-version/change-event state and no way for the caller to know what landed.Type of change:
High-level design:
N/A — small change. The fix mirrors the established
EntityRepository.restoreEntitypattern (and the approval path inChangeApplyService.applythat already drives the samelinkPorts+recordPortChangewrites): drop the inert@TransactionfrombulkPortsOperationand wrap each of the four public entry points (bulkAddInputPorts/bulkRemoveInputPorts/bulkAddOutputPorts/bulkRemoveOutputPorts) inexecuteInTransaction(() -> ...). This funnels the whole multi-statement write through onedaoCollection.inTransactionscope, so relationship rows, the change-event insert, and the entity store commit or roll back together, with deadlock retry and post-commit deferral handled byexecuteInTransaction. A comment documents the inert-annotation pitfall, matching the convention inEntityRepository.Tests:
Use cases covered
@Transactionpattern is structurally rejected going forward on the bulk-ports write path.Unit tests
openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/DataProductRepositoryTransactionTest.java— reflection guard assertingbulkPortsOperationis not annotated with@Transactionand the four publicbulk*Portsentry points returnBulkOperationResultand are not@Transaction-annotated. Prevents the inert-annotation copy-paste drift (the report notes it was copied from a 2023 inert pattern and the codebase's own warning was never propagated here) from being reintroduced.Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductPortsAtomicityIT.java— atomicity IT using the row-lock visibility pattern fromDataProductDeleteRaceIT: holdsSELECT ... FOR UPDATEon thedata_product_entityrow so a bulk-port request blocks atrecordPortChange'sstoreEntity(afterlinkPortshas issued its per-port writes), then asserts from a second connection that zero port rows are visible while blocked (pre-fix the per-port writes auto-committed and were visible). Registered in theglobal-statelane viaopenmetadata-integration-tests/pom.xml(mirroringDataProductDeleteRaceIT's include/exclude pairs across all engine profiles).PR checks run only the Java unit tests; the integration tests run in the merge queue and JavaUIIT / search-it nightly. For PR creation, record focused checks and list broader checks as pending. Merge readiness requires the full impacted plan. Tests are selected from
.github/java-tests/impact-map.json:make java_affected ARGS="--scope focused" # select focused checks; --scope full for merge readiness
make java_affected_run ARGS="--scope focused" # run once if no applicable evidence exists
make java_affected ARGS="--publish-results" # publish saved results without rerunning
Without
gh, drop--update-pr, pastetarget/java-tests/local-pr-results.mdbetween the markers, and posttarget/java-tests/local-pr-results-details.mdas a PR comment.make java_affected ARGS="--scope focused"plans the new unit test + the newDataProductPortsAtomicityIT(global-state, mysql-elasticsearch) plus the existingDataProductRepository-using unit classes.mvn test -pl openmetadata-service -Dtest=DataProductRepositoryTransactionTest→ 3 tests, 0 failures (BUILD SUCCESS). Verified it fails on the reverted fix (bulkPortsOperation must not carry @Transaction: expected: <false> but was: <true>), then passes again after restoring the fix.mvn -pl openmetadata-service,openmetadata-integration-tests spotless:check→ BUILD SUCCESS.mvn test -pl openmetadata-service -Dtest='DataProductRepositoryTransactionTest,EntityRepositoryTagCacheTest,PersonaContextBuilderTest,RuleEvaluatorTest'→ 83 tests, 0 failures (the focused unit set the planner selected).Verification also ran against a real OpenMetadata Dropwizard stack on Testcontainers MySQL 8.4.13 + Elasticsearch 9.3.0:
DataProductResourceIT(parallel lane, mysql-elasticsearch) → 295 tests, 0 failures, 28 skipped (@Disabledsystem-settings rules). Covers all port endpoints happy paths and pre-flight rejections.DataProductPortsAtomicityIT(global-state lane) → 2 tests, 0 failures on the fix. Verified it fails on the reverted fix exactly as the bug predicts:bulkAddInputPortsBlockedMidFlowExposesNoPartialRowsexpected: <0> but was: <4>(the per-port rows auto-committed while blocked) andbulkRemoveInputPortsBlockedMidFlowRemovesNoPartialRowsexpected: <4> but was: <0>(the per-port deletes auto-committed). Passes again after restoring the fix.WorkflowDefinitionResourceIT+DataProductDeleteRaceIT(global-state lane) → 160 tests, 0 failures — approval-gated ports path and the sibling row-lock race tests, no regression.DataProductDomainMigrationIT+DataProductDomainContainmentMigrationIT(parallel lane) → 13 tests, 0 failures — domain/asset port-migration paths, no regression.Pending (run in merge-queue CI): the
--scope fullplan — the full impacted IT suite acrossmysql-elasticsearch,postgres-opensearch,cache-tests, andrdflanes/engines. Not run here because the host has 4.8 GiB RAM and the reactor-wide recompile (-am) of the full IT set OOMs javac; the focused lane subset above covers the directly-impacted paths on the default engine. The Postgres+OpenSearch re-run ofDataProductResourceIT(to confirm rollback semantics on a second DB engine) is also deferred to merge-queue CI on the same memory budget.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
End-to-end against the running server is covered by the integration tests above (the Dropwizard app started on a real port against Testcontainers MySQL+ES, and the SDK exercised the actual
PUT /v1/dataProducts/.../inputPorts/addand/removeendpoints over HTTP, asserting both theBulkOperationResultresponse and the persistedentity_relationship/entity-version state).UI screen recording:
Not applicable — backend-only change (no
.ts/.tsxfiles touched).Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.docs/decisions/(see itsREADME.md). This description is gone fromgit logafter the squash-merge.Automatic Fixes PRs can be configured here.


Confidence Score: 5/5
The reviewed changes appear safe to merge.Summary
The PR wraps all four bulk-port methods in
executeInTransaction, removes the ineffective private@Transactionannotation, and registers tests that check writes from a second database connection.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Bulk port request] --> B[executeInTransaction] B --> C[Check ports and approval requirements] C --> D[Write relationships, change event, and entity] D --> E{Write succeeds?} E -->|Yes| F[Commit together] E -->|No| G[Roll back together]Reviews (4) · Last reviewed commit: "Drop annotation-only DataProductReposito..." · Reviewed by Greptile