Skip to content

[2.1] Fixes #38355: wrap Data Product bulk ports writes in a real transaction - #38515

Merged
yan-3005 merged 1 commit into
2.1from
backport/2.1/pr-38392
Nov 24, 2026
Merged

yan-3005 merged 1 commit into
2.1from
backport/2.1/pr-38392

Conversation

@gh-bot-collate

@gh-bot-collate gh-bot-collate Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Automated backport of #38392 to 2.1.

Source PR #38392
Author @detail-app[bot]
Merge commit 146d6ed8a640c75438e12ac60d1dba205880912d
Method Clean cherry-pick — identical to the commit on main.

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

RetriggerView in GreptileConfidence Score: 4/5

The transaction change appears sound, but the explicit Java import requirement must be satisfied before merging.

Findings

  1. P2 Tests leave records behind ▶
  2. P2 Rollback lacks test coverage ▶
  3. P2 Java import rule is unmet ▶

Summary

Wraps all four bulk port methods in executeInTransaction so relationship rows, the change event, and the entity store share one transaction.

  • Bulk Data Product port changes now commit all their stored updates together.

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
  end
Loading

Reviews (1) · Last reviewed commit: "Fixes #38355: wrap Data Product bulk por..." · Reviewed by Greptile

…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)
@gh-bot-collate
gh-bot-collate Bot requested a review from a team as a code owner November 23, 2026 16:12
@gh-bot-collate
gh-bot-collate Bot requested review from mohityadav766 and removed request for a team November 23, 2026 16:12
@gh-bot-collate gh-bot-collate Bot added the safe to test Add this label to run secure Github workflows on PRs label Nov 23, 2026
@gh-bot-collate

Copy link
Copy Markdown
Author

🤖 This backport will not merge itself: 2.1 has no required status checks, so there is nothing for auto-merge to wait on. Merge it by hand once CI is green.

Comment on lines +202 to +216
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())));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Tests leave records behind

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.

Comment on lines +135 to +147
// 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");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Rollback lacks test coverage

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Java import rule is unmet

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!

@yan-3005 yan-3005 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean cherry-pick of #38392 (identical patch-id), verified on main.

@yan-3005
yan-3005 merged commit ba4886d into 2.1 Nov 24, 2026
51 checks passed
@yan-3005
yan-3005 deleted the backport/2.1/pr-38392 branch November 24, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants