zeroshade commented on code in PR #2622:
URL: https://github.com/apache/iceberg-go/pull/2622#discussion_r4603844064
##########
table/update_schema.go:
##########
@@ -1108,6 +1108,14 @@ func (u *UpdateSchema) BuildUpdates() ([]Update,
[]Requirement, error) {
if existingSchemaID != u.schema.ID {
requirements = append(requirements,
AssertCurrentSchemaID(u.schema.ID))
if existingSchemaID == -1 {
+ // A stale writer must not reuse field IDs assigned
since its
+ // base. Skipped when the stored last-column-id is
below the
+ // schema history: the catalog and the transaction then
disagree
+ // on the counter and every commit would fail.
+ base := u.txn.tbl.Metadata()
+ if base.LastColumnID() ==
columnIDFloor(base.LastColumnID(), base.Schemas()) {
+ requirements = append(requirements,
AssertLastAssignedFieldID(base.LastColumnID()))
Review Comment:
Could this get an entry under "Unreleased compatibility notes" in
`website/src/releases.md`? Users will see the change: a stale `UpdateSchema`
that adds a column now fails with `table.ErrCommitFailed` when another writer
has assigned field IDs since its base (for example by adding and then dropping
a column), where it used to commit silently. Something like:
> **Schema updates assert the last assigned field ID.** When `UpdateSchema`
adds a schema, the commit now also requires the table's `last-column-id` to
match the transaction's base, as Iceberg Java does. A stale writer whose base
predates another writer's column additions now fails with
`table.ErrCommitFailed` instead of reusing field IDs. Reload the table and
reapply the schema change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]