s3tables: keep a table's root on update and rename (#13156)

* s3tables, lance: an update cannot move a table's or view's root

UpdateTable and UpdateView may move a record to another root (the move is
reserved while it happens: moveCatalogRecord, ExtendedKeyMoving). The old
root is then claimed by no record, although the table's older snapshots
still name files under it: a table registered or created over it loads
them and is vended credentials for them, and its drop purges them.
Reproduced on master: table u moved from ns/udir to ns/u2, an alias
created at ns/udir, the alias dropped: u's first snapshot's data file is
gone.

An update whose metadata location gives the record another root is now
refused with 400 InvalidRequest (ErrLocationMove) before anything is
written. No client path needs a move: a commit writes under the location
the record has (a table created without a location commits at its
assigned directory; a table renamed into another namespace keeps
committing at its directory, #12515). Lance's Overwrite register at
another dataset goes through UpdateTable and is refused the same way; an
Overwrite at the table's own location still works. The move reservation
stays (a reservation a crashed move left is still cleared by the next
update).

Tests: TestUpdateCannotMoveATablesRoot (the move refused, an alias over
the old root refused, the old snapshot's file kept, an update under the
table's own root works). Existing tests adapted to the rule, none
deleted: the UpdateTable refusals of TestLocationOwnedByOneRecord, the
moving subtests of TestLocationRaceBacksOut and
TestMoveReservationLeftBehind expect 400 with nothing written;
TestUpdateAfterRenameAcrossNamespacesRefusesAnotherTablesDirectory and
TestUpdateAfterRenameAcrossNamespacesMayMoveIntoItsNamespace expect
ErrLocationMove; vector_namespace_test.go's UpdateTable keeps the index's
root so its write reaches the fence it tests; lance
TestRegisterOverwriteKeepsTheOldDataset expects 400 for an Overwrite at
another dataset, the location unchanged and the dataset kept. Each
refusal is red with it replaced by the claim check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3tables: a record without a stored location is not renamed

A rename moves the catalog record and leaves the files where they are. A
record with neither a metadata location nor a warehouse location (every
Lance dataset, which lives at its name path; an Iceberg table created at
its name path by an older build) takes the root of its record path, so
after a rename it claims its new, empty name path and the files at the
old one belong to no record: a table created under the old name sits on
them. Reproduced on master: Lance table l renamed to l2, ns.l declared
again, l2's _versions/1.manifest is under the new ns.l.

A rename whose record would claim another root at its destination than
at its source is now refused with 400 InvalidRequest, after the
authorization checks (a caller without rights is answered as before). A
record with a stored location keeps its root and renames as before,
within its namespace or into another. In the vector namespace of a
vector bucket the read-only answer its fence gives stays the answer.

Tests: TestRenameRefusesARecordWithoutAStoredLocation: a Lance dataset
renamed in its namespace and a location-less Iceberg table renamed into
another are refused, both records and the dataset's files stay; a table
with a stored location renames (positive control). Adapted: the rename
subtest of TestLocationRaceBacksOut (its table has no stored location)
expects 400 with nothing written. Red with the refusal removed, and
TestVectorNamespaceIsReadOnlyOverLance/rename_out with the vector
namespace's answer skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Javier de la Torre <jatorre@carto.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-11-30 11:29:04 -08:00
1 parent 442e0a24c6
commit 79b4a8ab31
8 files changed
+136 -40

No files matched your search

+15 -9
View File
@@ -228,28 +228,34 @@ func TestTableLifecycle(t *testing.T) {
}
}
// Repointing a registered name at another dataset must not take the dataset it
// used to name with it.
// Repointing a registered name at another dataset (Overwrite) would move its
// root: the dataset it named would be left to no catalog record, and the next
// table placed there could take it. The catalog refuses the move (400) and keeps
// the old dataset where it is; an Overwrite at the table's own location works.
func TestRegisterOverwriteKeepsTheOldDataset(t *testing.T) {
h := newTestHarness(t)
h.createBucket(t, "analytics", s3tables.FormatLance)
h.mustDo(t, http.MethodPost, "/v1/namespace/analytics$sales/create", `{}`, http.StatusOK)
h.mustDo(t, http.MethodPost, "/v1/table/analytics$sales$orders/declare", `{}`, http.StatusOK)
h.mustDo(t, http.MethodPost, "/v1/table/analytics$sales$current/declare", `{}`, http.StatusOK)
declared := decode[DeclareTableResponse](t,
h.mustDo(t, http.MethodPost, "/v1/table/analytics$sales$orders/declare", `{}`, http.StatusOK))
current := decode[DeclareTableResponse](t,
h.mustDo(t, http.MethodPost, "/v1/table/analytics$sales$current/declare", `{}`, http.StatusOK))
h.mustDo(t, http.MethodPost, "/v1/table/analytics$sales$orders/register",
`{"location":"s3://analytics/sales/current","mode":"Overwrite"}`, http.StatusConflict)
`{"location":"`+current.Location+`","mode":"Overwrite"}`, http.StatusBadRequest)
h.mustDo(t, http.MethodPost, "/v1/table/analytics$sales$orders/register",
`{"location":"s3://analytics/sales/archive","mode":"Overwrite"}`, http.StatusOK)
`{"location":"s3://analytics/sales/archive","mode":"Overwrite"}`, http.StatusBadRequest)
described := decode[DescribeTableResponse](t,
h.mustDo(t, http.MethodPost, "/v1/table/analytics$sales$orders/describe", `{}`, http.StatusOK))
if described.Location != "s3://analytics/sales/archive" {
t.Fatalf("location after repointing = %q", described.Location)
if described.Location != declared.Location {
t.Fatalf("location after a refused repoint = %q, want %q", described.Location, declared.Location)
}
if h.filer.Get(s3tables.GetNamespacePath("analytics", "sales"), "orders") == nil {
t.Fatal("repointing deleted the dataset the name used to hold")
t.Fatal("a refused repoint deleted the dataset the name holds")
}
h.mustDo(t, http.MethodPost, "/v1/table/analytics$sales$orders/register",
`{"location":"`+declared.Location+`","mode":"Overwrite"}`, http.StatusOK)
}
// A required list field answers empty rather than null, which a generated
+1
View File
@@ -27,6 +27,7 @@ var (
ErrConcurrentUpdate = errors.New("attribute changed concurrently")
ErrNameTaken = errors.New("catalog name is taken")
ErrLocationInUse = errors.New("location is in use by another table or view")
ErrLocationMove = errors.New("a table's or view's location cannot be changed; commits write under the location it has")
// ErrPublishedRecordChanged is the ErrConcurrentUpdate a create returns
// when the record it wrote was already visible, and another caller changed
// it — updated it, or renamed it away — before the create could back it
@@ -7,6 +7,7 @@ import (
"net/http"
"path"
"testing"
"time"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3tables/s3tablestest"
@@ -50,7 +51,10 @@ func TestLocationOwnedByOneRecord(t *testing.T) {
refused(t, "CreateTable", &CreateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "alias", Format: FormatLance, MetadataLocation: renameLocation(location)})
refused(t, "RegisterTable", &RegisterTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "alias", MetadataLocation: renameLocation(location)})
refused(t, "CreateView", &CreateViewRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "alias", MetadataLocation: renameLocation(location)})
refused(t, "UpdateTable", &UpdateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "own", MetadataVersion: 2, MetadataLocation: renameLocation(location)})
// the catalog refuses any update that moves a record's root (ErrLocationMove), before it looks at who holds the new one
status, resp := runHandler(t, m, fs.Client, "UpdateTable", &UpdateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "own", MetadataVersion: 2, MetadataLocation: renameLocation(location)})
assert.Equal(t, http.StatusBadRequest, status, "UpdateTable: %+v", resp)
assert.NotContains(t, resp.Message, "ns/t")
}
assert.Nil(t, fs.Get(GetNamespacePath(renameTestBucket, "ns"), "alias"))
}
@@ -187,8 +191,9 @@ func TestLocationRaceBacksOut(t *testing.T) {
status, resp := runHandler(t, m, client, "UpdateTable", &UpdateTableRequest{
TableBucketARN: mustBucketARN(t), Namespace: []string{"ns"}, Name: "t", MetadataVersion: 4, MetadataLocation: location,
})
assert.Equal(t, http.StatusConflict, status, "%+v", resp)
require.True(t, client.planted)
// the catalog refuses the move before it writes anything (ErrLocationMove)
assert.Equal(t, http.StatusBadRequest, status, "%+v", resp)
require.False(t, client.planted)
assert.Equal(t, string(before), string(fs.Get(nsPath, "t").Extended[ExtendedKeyMetadata]))
assert.NotContains(t, fs.Get(nsPath, "t").Extended, ExtendedKeyMoving)
})
@@ -208,15 +213,12 @@ func TestLocationRaceBacksOut(t *testing.T) {
update = &UpdateViewRequest{TableBucketARN: mustBucketARN(t), Namespace: []string{"ns"}, Name: "a", MetadataVersion: 2, MetadataLocation: location}
}
before := fs.Get(nsPath, "a").Extended[ExtendedKeyMetadata]
var oldRootErr error
client := &rootRaceClient{SeaweedFilerClient: fs.Client, f: fs, dir: nsPath, name: "a", location: location}
client.then = func() {
oldRootErr = checkLocationUnclaimed(context.Background(), fs.Client, renameTestBucket, path.Join(nsPath, "b"), CatalogRecordRoot(renameTestBucket, path.Join(nsPath, "b"), oldLocation, ""))
}
status, resp := runHandler(t, m, client, operation, update)
assert.Equal(t, http.StatusConflict, status, "%+v", resp)
require.True(t, client.planted)
assert.ErrorIs(t, oldRootErr, ErrLocationInUse)
// the catalog refuses the move before it writes anything (ErrLocationMove): the old root stays the record's
assert.Equal(t, http.StatusBadRequest, status, "%+v", resp)
require.False(t, client.planted)
assert.ErrorIs(t, checkLocationUnclaimed(context.Background(), fs.Client, renameTestBucket, path.Join(nsPath, "b"), CatalogRecordRoot(renameTestBucket, path.Join(nsPath, "b"), oldLocation, "")), ErrLocationInUse)
assert.Equal(t, string(before), string(fs.Get(nsPath, "a").Extended[ExtendedKeyMetadata]))
assert.NotContains(t, fs.Get(nsPath, "a").Extended, ExtendedKeyMoving)
})
@@ -233,8 +235,9 @@ func TestLocationRaceBacksOut(t *testing.T) {
runHandler(t, m, fs.Client, "UpdateTable", &UpdateTableRequest{TableBucketARN: mustBucketARN(t), Namespace: []string{"ns"}, Name: "a", MetadataVersion: 3, MetadataLocation: renameLocation(other)})
}
status, resp := runHandler(t, m, client, "UpdateTable", &UpdateTableRequest{TableBucketARN: mustBucketARN(t), Namespace: []string{"ns"}, Name: "a", MetadataVersion: 2, MetadataLocation: location})
assert.Equal(t, http.StatusConflict, status, "%+v", resp)
require.True(t, client.planted)
// refused before anything is written (ErrLocationMove)
assert.Equal(t, http.StatusBadRequest, status, "%+v", resp)
require.False(t, client.planted)
assert.False(t, RootClaimed(mustRoots(t, fs), path.Join(nsPath, "rival"), path.Join(nsPath, "shared")))
assert.NotContains(t, fs.Get(nsPath, "a").Extended, ExtendedKeyMoving)
})
@@ -247,8 +250,9 @@ func TestLocationRaceBacksOut(t *testing.T) {
status, resp := runHandler(t, m, client, "UpdateTable", &UpdateTableRequest{
TableBucketARN: mustBucketARN(t), Namespace: []string{"ns"}, Name: "t", MetadataVersion: 4, MetadataLocation: location,
})
assert.NotEqual(t, http.StatusOK, status, "%+v", resp)
require.True(t, client.failing)
// refused before anything is written (ErrLocationMove)
assert.Equal(t, http.StatusBadRequest, status, "%+v", resp)
require.False(t, client.failing)
assert.Equal(t, string(before), string(fs.Get(nsPath, "t").Extended[ExtendedKeyMetadata]))
assert.NotContains(t, fs.Get(nsPath, "t").Extended, ExtendedKeyMoving)
})
@@ -261,8 +265,9 @@ func TestLocationRaceBacksOut(t *testing.T) {
status, resp := runHandler(t, m, client, "RenameTable", &RenameTableRequest{
TableBucketARN: mustBucketARN(t), SourceNamespace: []string{"ns"}, SourceName: "c", DestNamespace: []string{"ns"}, DestName: "dest",
})
assert.Equal(t, http.StatusConflict, status, "%+v", resp)
require.True(t, client.planted)
// c has no stored location: the catalog refuses its rename before anything is written
assert.Equal(t, http.StatusBadRequest, status, "%+v", resp)
require.False(t, client.planted)
assert.Contains(t, fs.Get(nsPath, "c").Extended, ExtendedKeyMetadata)
if entry := fs.Get(nsPath, "dest"); entry != nil {
assert.NotContains(t, entry.Extended, ExtendedKeyMetadata)
@@ -285,13 +290,15 @@ func TestMoveReservationLeftBehind(t *testing.T) {
refused := renameLocation("ns/moved/metadata/v1.metadata.json")
assert.True(t, RootClaimed(mustRoots(t, fs), path.Join(nsPath, "other"), path.Join(nsPath, "elsewhere")))
status, resp := runHandler(t, m, fs.Client, "UpdateTable", &UpdateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "t", MetadataVersion: 4, MetadataLocation: refused})
assert.Equal(t, http.StatusConflict, status, "%+v", resp)
// the catalog refuses every move (ErrLocationMove)
assert.Equal(t, http.StatusBadRequest, status, "%+v", resp)
requireOK(t, m, fs, "UpdateTable", &UpdateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "t", MetadataVersion: 4, MetadataLocation: renameLocation("ns/t/metadata/v4.metadata.json")})
assert.NotContains(t, fs.Get(nsPath, "t").Extended, ExtendedKeyMoving)
assert.False(t, RootClaimed(mustRoots(t, fs), path.Join(nsPath, "other"), path.Join(nsPath, "elsewhere")))
requireOK(t, m, fs, "UpdateTable", &UpdateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "t", MetadataVersion: 5, MetadataLocation: refused})
status, resp = runHandler(t, m, fs.Client, "UpdateTable", &UpdateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "t", MetadataVersion: 5, MetadataLocation: refused})
assert.Equal(t, http.StatusBadRequest, status, "%+v", resp)
assert.NotContains(t, fs.Get(nsPath, "t").Extended, ExtendedKeyMoving)
}
@@ -385,3 +392,37 @@ func TestRecordGoneDropsItsMoveReservation(t *testing.T) {
reuse(t, m, fs, "d")
})
}
// An update may not move a table's root: its older snapshots keep naming files
// under the root it has, which a move would leave to no record. A table then
// registered over that root would load them, and its drop would purge them.
func TestUpdateCannotMoveATablesRoot(t *testing.T) {
fs, m := startRenameManager(t)
bucketARN := mustBucketARN(t)
nsPath := GetNamespacePath(renameTestBucket, "ns")
requireOK(t, m, fs, "CreateTable", &CreateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "u", Format: FormatIceberg,
MetadataLocation: renameLocation("ns/udir/metadata/v1.metadata.json")})
udata := path.Join(GetTablePath(renameTestBucket, "ns", "udir"), "data")
fs.Put(nsPath, "udir", nil)
fs.Put(GetTablePath(renameTestBucket, "ns", "udir"), "data", nil)
fs.PutFile(udata, "snap1.parquet", time.Now())
before := fs.Get(nsPath, "u").Extended[ExtendedKeyMetadata]
status, resp := runHandler(t, m, fs.Client, "UpdateTable", &UpdateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "u",
MetadataVersion: 2, MetadataLocation: renameLocation("ns/u2/metadata/v2.metadata.json")})
assert.Equal(t, http.StatusBadRequest, status, "%+v", resp)
assert.Equal(t, string(before), string(fs.Get(nsPath, "u").Extended[ExtendedKeyMetadata]))
// the old root stays u's: an alias over it is refused, and u's files stay
status, resp = runHandler(t, m, fs.Client, "RegisterTable", &RegisterTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "alias",
MetadataLocation: renameLocation("ns/udir/metadata/v1.metadata.json")})
if status == http.StatusOK {
runHandler(t, m, fs.Client, "DeleteTable", &DeleteTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "alias"})
}
assert.Equal(t, http.StatusConflict, status, "an alias over u's root: %+v", resp)
assert.NotNil(t, fs.Get(udata, "snap1.parquet"), "u's earlier snapshot files")
// positive control: an update under the root u has works
requireOK(t, m, fs, "UpdateTable", &UpdateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "u",
MetadataVersion: 2, MetadataLocation: renameLocation("ns/udir/metadata/v2.metadata.json")})
}
@@ -543,3 +543,35 @@ func TestRenameReadsMatchSnapshot(t *testing.T) {
})
}
}
// A rename moves the catalog record, never the files. A record without a
// stored location (a Lance dataset; a table of an older build at its name
// path) keeps its files at its name path, so its rename is refused: the record
// would claim the new name path, and the next table created under the old name
// would sit on the dataset (load it, get credentials for it, purge it with its
// drop). A table with a stored location renames as before.
func TestRenameRefusesARecordWithoutAStoredLocation(t *testing.T) {
fs, m := startRenameManager(t)
bucketARN := mustBucketARN(t)
addRenameNamespace(t, fs, "ns2")
requireOK(t, m, fs, "CreateTable", &CreateTableRequest{TableBucketARN: bucketARN, Namespace: []string{"ns"}, Name: "l", Format: FormatLance})
lpath := GetTablePath(renameTestBucket, "ns", "l")
fs.Put(lpath, "_versions", nil)
fs.PutFile(path.Join(lpath, "_versions"), "1.manifest", time.Now())
bare, err := json.Marshal(tableMetadataInternal{Name: "bare", Namespace: "ns", Format: FormatIceberg, OwnerAccountID: DefaultAccountID, VersionToken: "v1"})
require.NoError(t, err)
fs.Put(GetNamespacePath(renameTestBucket, "ns"), "bare", map[string][]byte{ExtendedKeyMetadata: bare, ExtendedKeyEntryType: []byte(EntryTypeTable)})
for _, rename := range []*RenameTableRequest{
{TableBucketARN: bucketARN, SourceNamespace: []string{"ns"}, SourceName: "l", DestNamespace: []string{"ns"}, DestName: "l2"},
{TableBucketARN: bucketARN, SourceNamespace: []string{"ns"}, SourceName: "bare", DestNamespace: []string{"ns2"}, DestName: "bare"},
} {
status, resp := runHandler(t, m, fs.Client, "RenameTable", rename)
assert.Equal(t, http.StatusBadRequest, status, "rename %s: %+v", rename.SourceName, resp)
assert.Contains(t, fs.Get(GetNamespacePath(renameTestBucket, "ns"), rename.SourceName).Extended, ExtendedKeyMetadata)
}
assert.NotNil(t, fs.Get(path.Join(lpath, "_versions"), "1.manifest"))
// positive control: a table with a stored location renames
requireOK(t, m, fs, "RenameTable", &RenameTableRequest{TableBucketARN: bucketARN, SourceNamespace: []string{"ns"}, SourceName: "t", DestNamespace: []string{"ns2"}, DestName: "t"})
}
+12 -6
View File
@@ -1764,10 +1764,17 @@ func (h *S3TablesHandler) renameCatalogEntry(w http.ResponseWriter, r *http.Requ
if err := h.refuseClaimedNamespace(w, r, filerClient, destNamespacePath, destNamespace, isDestNamespace); err != nil {
return err
}
if metadata.root(bucketName, srcPath) == srcPath {
if err := h.refuseClaimedLocation(w, r, filerClient, bucketName, destPath, destPath); err != nil {
return err
// a rename moves the record, not the files: a record rooted at its name path stays put
if metadata.root(bucketName, srcPath) != metadata.root(bucketName, destPath) {
for _, namespace := range [][]string{req.SourceNamespace, req.DestNamespace} {
if vectorErr := h.checkVectorNamespaceWrite(r.Context(), filerClient, bucketName, namespace); vectorErr != nil {
h.writeError(w, http.StatusForbidden, ErrCodeAccessDenied, vectorNamespaceReadOnly)
return vectorErr
}
}
message := fmt.Sprintf("a %s without a stored location cannot be renamed: its files stay at its name path", kind.noun)
h.writeError(w, http.StatusBadRequest, ErrCodeInvalidRequest, message)
return errors.New(message)
}
metadata.Name = destName
@@ -2206,9 +2213,8 @@ func (h *S3TablesHandler) handleUpdateTable(w http.ResponseWriter, r *http.Reque
newRoot := CatalogRecordRoot(target.bucketName, target.tablePath, req.MetadataLocation, metadata.WarehouseLocation)
movesRoot := req.MetadataLocation != "" && newRoot != metadata.root(target.bucketName, target.tablePath)
if movesRoot {
if err := h.refuseClaimedLocation(w, r, filerClient, target.bucketName, target.tablePath, newRoot); err != nil {
return err
}
h.writeError(w, http.StatusBadRequest, ErrCodeInvalidRequest, ErrLocationMove.Error())
return ErrLocationMove
}
if req.MetadataLocation != "" {
metadata.MetadataLocation = req.MetadataLocation
@@ -85,12 +85,14 @@ func TestUpdateAfterRenameAcrossNamespacesRefusesAnotherTablesDirectory(t *testi
require.Error(t, err)
require.Contains(t, s3TablesErrorText(err), "must be within namespace ns2")
// One the current namespace holds: inside the namespace, but claimed.
// One the current namespace holds: inside the namespace, but another root.
// The catalog refuses every update that moves a record's root, before it
// looks at who holds the new one (ErrLocationMove).
fs, m = renamedAcrossNamespaces(t)
seedRenameTable(t, fs, "ns2", "w")
err = updateTableAt(context.Background(), t, m, fs, "ns2", "s3://"+renameTestBucket+"/ns2/w/metadata/v9.metadata.json")
require.Error(t, err)
require.Contains(t, s3TablesErrorText(err), ErrCodeConflict+": location is in use")
require.Contains(t, s3TablesErrorText(err), ErrLocationMove.Error())
}
// A table created under the renamed table's old name has its entry on that
@@ -128,9 +130,15 @@ func TestUpdateRefusesADirectoryOutsideTheNamespaceThatAnotherTableShares(t *tes
require.Contains(t, s3TablesErrorText(err), "must be within namespace ns2")
}
// The catalog refuses every update that moves a record's root (ErrLocationMove):
// a renamed table keeps committing under the directory it has
// (TestUpdateAfterRenameAcrossNamespacesKeepsItsDirectory) and does not move
// into its new namespace, where its older snapshots' files are not.
func TestUpdateAfterRenameAcrossNamespacesMayMoveIntoItsNamespace(t *testing.T) {
fs, m := renamedAcrossNamespaces(t)
require.NoError(t, updateTableAt(context.Background(), t, m, fs, "ns2", "s3://"+renameTestBucket+"/ns2/t-moved/metadata/v4.metadata.json"))
err := updateTableAt(context.Background(), t, m, fs, "ns2", "s3://"+renameTestBucket+"/ns2/t-moved/metadata/v4.metadata.json")
require.Error(t, err)
require.Contains(t, s3TablesErrorText(err), ErrLocationMove.Error())
}
func TestUpdateStillConfinesAMoveToTheTablesNamespace(t *testing.T) {
+2 -3
View File
@@ -571,9 +571,8 @@ func (h *S3TablesHandler) handleUpdateView(w http.ResponseWriter, r *http.Reques
newRoot := CatalogRecordRoot(target.bucketName, viewPath, req.MetadataLocation, metadata.WarehouseLocation)
movesRoot := req.MetadataLocation != "" && newRoot != metadata.root(target.bucketName, viewPath)
if movesRoot {
if err := h.refuseClaimedLocation(w, r, filerClient, target.bucketName, viewPath, newRoot); err != nil {
return err
}
h.writeError(w, http.StatusBadRequest, ErrCodeInvalidRequest, ErrLocationMove.Error())
return ErrLocationMove
}
if req.MetadataLocation != "" {
metadata.MetadataLocation = req.MetadataLocation
+4 -1
View File
@@ -76,8 +76,11 @@ func vectorNamespaceWrites(t *testing.T, indexARN, versionToken string) []vector
{"CreateTable", &CreateTableRequest{TableBucketARN: arn, Namespace: vector, Name: "fresh", Format: FormatLance}},
{"RegisterTable", &RegisterTableRequest{TableBucketARN: arn, Namespace: vector, Name: "registered",
MetadataLocation: "s3://" + vectorTestBucket + "/vector/registered/metadata/v1.metadata.json"}},
// at idx's own root: the catalog refuses an update that moves a record's root
// before anything is written (ErrLocationMove), so only a write the fence
// sees tests the fence
{"UpdateTable", &UpdateTableRequest{TableBucketARN: arn, Namespace: vector, Name: "idx", VersionToken: versionToken,
MetadataLocation: "s3://" + vectorTestBucket + "/vector/elsewhere"}},
MetadataLocation: "s3://" + vectorTestBucket + "/vector/idx"}},
{"DeleteTable", &DeleteTableRequest{TableBucketARN: arn, Namespace: vector, Name: "idx"}},
{"RenameTable out", &RenameTableRequest{TableBucketARN: arn, SourceNamespace: vector, SourceName: "idx",
DestNamespace: []string{"other"}, DestName: "moved"}},