Skip to content

Fix: Group transaction changes by table - #3360

Merged
singhpk234 merged 3 commits into
apache:mainfrom
singhpk234:feature/optimize-transaction
Mar 6, 2026
Merged

singhpk234 merged 3 commits into
apache:mainfrom
singhpk234:feature/optimize-transaction

Conversation

@singhpk234

@singhpk234 singhpk234 commented Jan 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

. Groups ALL changes by table- even if they appear randomly in the input like [A1, B1, A2, C1, A3] → groups to {A:
[A1, A2, A3], B: [B1], C: [C1]}
2. For each table, processes changes sequentially :
- Validate R1 against base metadata → Apply U1 → update currentMetadata
- Validate R2 against updated metadata → Apply U2 → update currentMetadata
- Validate R3 against updated metadata → Apply U3 → update currentMetadata
3. Single commit per table prevents duplicate entity IDs in pendingUpdates

This ensures:

  • Each change's requirements validate against the evolved state
  • Updates are applied in order within each table
  • Only one commit per table (solves the original problem)
  • Conflicts detected early (e.g., second change expecting schema ID 0 fails when it's already 1)

related discussion: #3352 (comment)

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Jan 6, 2026
@singhpk234 singhpk234 changed the title Fix: Group transaction changes by table in a transaction Fix: Group transaction changes by table Jan 6, 2026
@sfc-gh-prsingh
sfc-gh-prsingh force-pushed the feature/optimize-transaction branch 2 times, most recently from 2380846 to e0f05c0 Compare January 6, 2026 02:53
@dimas-b

dimas-b commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

nit: Only one commit per table (solves the original problem) - I'd simply say Only one commit per table. This will end up in the git commit log, where the "original problem" might be hard to understand later on... It's also fine to give a summary of the problem instead of the "original" reference if you prefer.

dimas-b
dimas-b previously approved these changes Jan 6, 2026

@dimas-b dimas-b 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.

Nice fix. Thanks, @singhpk234 !

Just a couple of minor comments :)

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jan 6, 2026
dennishuo
dennishuo previously approved these changes Jan 7, 2026

@adnanhemani adnanhemani 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.

Awesome change!

@github-actions

github-actions Bot commented Feb 9, 2026

Copy link
Copy Markdown

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions Bot added the stale label Feb 9, 2026
@singhpk234 singhpk234 removed the stale label Feb 9, 2026
@sfc-gh-prsingh
sfc-gh-prsingh dismissed stale reviews from dennishuo and dimas-b via 8f1fe58 February 26, 2026 06:53
@sfc-gh-prsingh
sfc-gh-prsingh force-pushed the feature/optimize-transaction branch from e0f05c0 to 8f1fe58 Compare February 26, 2026 06:53
@singhpk234

Copy link
Copy Markdown
Contributor Author

Apologies it took me a while to get back to it, was super swamped with internal stuff.
Addressed @dennishuo feedback to add detailed comment.
Addressed @flyrain's offline feedback to add more tests to iron this.

Please have another pass when you all get some time, really apprecaite your feedbacks here !

@singhpk234 singhpk234 added this to the 1.5.0 milestone Feb 26, 2026
@dimas-b

dimas-b commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

@singhpk234 : thanks for pushing this forward 👍 Please fix fresh IcebergCatalogHandler conflicts 😅

@sfc-gh-prsingh
sfc-gh-prsingh force-pushed the feature/optimize-transaction branch from 8f1fe58 to 90296e0 Compare February 26, 2026 17:43

@flyrain flyrain 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.

LGTM. Thanks @singhpk234 !

Comment on lines +1089 to +1090
&& !realmConfig()
.getConfig(FeatureConfiguration.ALLOW_NAMESPACE_LOCATION_OVERLAP)) {

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.

This check allows the operation setLocation when ALLOW_NAMESPACE_LOCATION_OVERLAP is true. I think the behavior isn't correct. cc @dennishuo @collado-mike
However, it isn't a blocker for me as this PR doesn't the logic.

Schema expectedSchema = updateSchema.apply();
updateSchema.commit();

transaction.updateProperties().set("prop-key", "prop-val").commit();

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.

Is behavior deterministic when we have two property updates like this?

  1. transaction.updateProperties().set("prop-key", "prop-val1").commit();
  2. transaction.updateProperties().set("prop-key", "prop-val2").commit();

If not, we may check with the Iceberg community to clarify the behavior. Not a blocker.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

within a transaction (taking iceberg's client side transcation as an example) it will be consistent as if prop-key value would be prop-val2 as we create a new metadata locally and keep on apply update on top of last updated metadata, is my understanding.

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.

Are updateRequests ordered? If not, the final result could be either val2 or val1.

@singhpk234 singhpk234 Mar 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@singhpk234
singhpk234 merged commit ae2efce into apache:main Mar 6, 2026
17 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Mar 6, 2026
@singhpk234

Copy link
Copy Markdown
Contributor Author

Thanks everyone for the review !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants