Repository navigation
[2.1] Fixes #38355: wrap Data Product bulk ports writes in a real transaction - #38515
Conversation
…on (#38392) * 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. --------- 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]> (cherry picked from commit 146d6ed)
|
🤖 This backport will not merge itself: |
| Domain domain = | ||
| client | ||
| .domains() | ||
| .create( | ||
| new CreateDomain() | ||
| .withName(ns.prefix("domain")) | ||
| .withDomainType(DomainType.AGGREGATE) | ||
| .withDescription("Domain of a data product whose ports are added mid-request")); | ||
| return client | ||
| .dataProducts() | ||
| .create( | ||
| new CreateDataProduct() | ||
| .withName(ns.prefix("dataProduct")) | ||
| .withDescription("Data product whose ports are added mid-request") | ||
| .withDomains(List.of(domain.getFullyQualifiedName()))); |
There was a problem hiding this comment.
createDataProduct creates a domain and data product without registering either with ns.trackRoot. TestNamespaceExtension deletes only registered roots, so both tests leave these records behind. Register the domain for recursive cleanup, or register both records in a safe deletion order.
| // The headline atomicity assertion: none of the per-port relationship rows committed yet. | ||
| assertEquals( | ||
| 0L, | ||
| countRows(EDGES_OF_INPUT_PORTS, dataProductId.toString()), | ||
| "No input-port relationship row may be visible while the bulk add is blocked at the" | ||
| + " entity store — the per-port writes must share the bulk operation's transaction"); | ||
| // The entity version has not advanced either: the version bump lives in storeEntity, which | ||
| // is blocked behind the held row lock, so a fresh read still sees the pre-request version. | ||
| DataProduct fresh = SdkClients.adminClient().dataProducts().get(dataProductId.toString()); | ||
| assertEquals( | ||
| dataProduct.getVersion(), | ||
| fresh.getVersion(), | ||
| "The data product version must not advance until the bulk add commits"); |
There was a problem hiding this comment.
The new tests check relationship visibility, but never read change_event or make the bulk request fail after its relationship writes. They would still pass if the event insert committed separately or a failure left partial writes behind.
Add a failure case that checks rollback of both relationship rows and the event. Also check that the event stays hidden while the successful request is blocked.
| Database database = | ||
| Databases.create().name(ns.prefix("db")).in(service.getFullyQualifiedName()).execute(); | ||
| DatabaseSchema schema = DatabaseSchemaTestFactory.create(ns, database.getFullyQualifiedName()); | ||
| return java.util.stream.IntStream.range(0, n) |
There was a problem hiding this comment.
The new test uses java.util.stream.IntStream here and java.util.function.Supplier in async. The Java guide requires imports instead of fully qualified class names in code. Import IntStream and Supplier to satisfy this repository requirement before merging.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Automated backport of #38392 to
2.1.146d6ed8a640c75438e12ac60d1dba205880912dmain.Opened from openmetadata-collate, which holds the credentials needed to open a PR here. It merges itself once this branch's required checks pass — no review needed. If a check fails it stays open and the author of #38392 is asked to look.
resolver run
The transaction change appears sound, but the explicit Java import requirement must be satisfied before merging.
Findings
Summary
Wraps all four bulk port methods in
executeInTransactionso relationship rows, the change event, and the entity store share one transaction.Diagram
sequenceDiagram participant C as Caller participant R as DataProductRepository participant D as Database participant H as Deferred handlers C->>R: Add or remove ports R->>D: Begin transaction R->>D: Write port relationships R->>D: Insert change event R->>D: Store data product alt All writes succeed R->>D: Commit R->>H: Run queued work R-->>C: Bulk result else A write fails R->>D: Roll back R->>R: Clear queued work endReviews (1) · Last reviewed commit: "Fixes #38355: wrap Data Product bulk por..." · Reviewed by Greptile