Skip to content

fix: recreating an existing namespace with OPTIMIZED_SIBLING_CHECK is a conflict - #5596

Merged
dimas-b merged 1 commit into
apache:mainfrom
andybradshaw:fix/namespace-recreate-returns-409
Sep 25, 2026
Merged

dimas-b merged 1 commit into
apache:mainfrom
andybradshaw:fix/namespace-recreate-returns-409

Conversation

@andybradshaw

Copy link
Copy Markdown
Contributor

Split out of #5520 as a separate PR, addressing the HTTP status code portion of #5521.

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)

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

LGTM 👍 Thanks, @andybradshaw !

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Sep 23, 2026

@ayushtkn ayushtkn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanx @andybradshaw for the fix, I think the title is wrong. It says recreating an existing table but the fix is recreating the namespace, the CHANGELOG is correct.

The table path may still have a gap. The same-name exclusion

siblingTables.forEach(
tbl -> {
if (!tbl.name().equals(name)) {
pathsToResolve.add(ResolvedPathKey.ofTableLike(tbl));
}
});
siblingNamespaces.forEach(
ns -> {
if (!ns.level(ns.length() - 1).equals(name)) {
pathsToResolve.add(ResolvedPathKey.ofNamespace(ns));
}
});

exists only in the fallback — the optimized path has no equivalent. And for tables, validateNoLocationOverlap

// Create a fake IcebergTableLikeEntity to check for overlap, since no real entity
// has been created yet.
var lastNamespace = resolvedNamespace.getLast();
IcebergTableLikeEntity virtualEntity =
IcebergTableLikeEntity.of(
new PolarisEntity.Builder()
.setName(identifier.name())
.setType(PolarisEntityType.TABLE_LIKE)
.setSubType(PolarisEntitySubType.ICEBERG_TABLE)
.setParentId(lastNamespace.getId())
.setCatalogId(lastNamespace.getCatalogId())
.setProperties(Map.of(PolarisEntityConstants.ENTITY_BASE_LOCATION, location))
.build());
validateNoLocationOverlap(virtualEntity, resolvedNamespace);

builds a virtual IcebergTableLikeEntity with no persisted id, so nothing could exclude the real one even with #5520's ancestor filtering. A sequential recreate won't show this — Iceberg's create() checks ops.current() and 409s first — but where a create reaches doCommit(null, …) with the entity already present, mainly concurrent same-name creates, the optimized path can surface 403 instead of 409. That also skips the AlreadyExistsException catch used for idempotency replay.

I think we should update the title to say it is namespace & maybe chase the table path as a followup.

@andybradshaw andybradshaw changed the title fix: recreating an existing table with OPTIMIZED_SIBLING_CHECK is a conflict fix: recreating an existing namespace with OPTIMIZED_SIBLING_CHECK is a conflict Sep 24, 2026
@dimas-b

dimas-b commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Good point about follow-up from @ayushtkn

Are we ok to merge this PR "as is" and do further improvements on main later?

@ayushtkn ayushtkn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me

@dimas-b
dimas-b merged commit 0b99819 into apache:main Sep 25, 2026
43 of 45 checks passed
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.

5 participants