SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
s3tables: fix cross-namespace pagination in listTablesInAllNamespaces
Chris Lu5c43f1e6a4ed
diff --git a/weed/s3api/s3tables/handler_table.go b/weed/s3api/s3tables/handler_table.goindex af514c9918..5d8c5502a2 100644--- a/weed/s3api/s3tables/handler_table.go+++ b/weed/s3api/s3tables/handler_table.go@@ -419,17 +419,18 @@ func (h *S3TablesHandler) listTablesInNamespaceWithClient(ctx context.Context, cfunc (h *S3TablesHandler) listTablesInAllNamespaces(ctx context.Context, filerClient FilerClient, bucketName, prefix, continuationToken string, maxTables int, tables *[]TableSummary) error {bucketPath := getTableBucketPath(bucketName)- var lastNamespace string+ var continuationNamespace stringvar startTableName stringif continuationToken != "" {if parts := strings.SplitN(continuationToken, "/", 2); len(parts) == 2 {- lastNamespace = parts[0]+ continuationNamespace = parts[0]startTableName = parts[1]} else {- lastNamespace = continuationToken+ continuationNamespace = continuationToken}}+ lastNamespace := continuationNamespacereturn filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {for {// List namespaces in batches@@ -437,7 +438,7 @@ func (h *S3TablesHandler) listTablesInAllNamespaces(ctx context.Context, filerClDirectory: bucketPath,Limit: 100,StartFromFileName: lastNamespace,- InclusiveStartFrom: lastNamespace == "",+ InclusiveStartFrom: lastNamespace == continuationNamespace && continuationNamespace != "" || lastNamespace == "",})if err != nil {return err@@ -455,6 +456,13 @@ func (h *S3TablesHandler) listTablesInAllNamespaces(ctx context.Context, filerClif entry.Entry == nil {continue}++ // Skip the start item if it was the continuation namespace but we already processed it+ // (handled by the startTableName clearing logic below)+ if lastNamespace == continuationNamespace && continuationNamespace != "" && entry.Entry.Name == continuationNamespace && startTableName == "" && len(*tables) > 0 {+ continue+ }+hasMore = truelastNamespace = entry.Entry.Name@@ -471,7 +479,7 @@ func (h *S3TablesHandler) listTablesInAllNamespaces(ctx context.Context, filerCl// List tables in this namespacetableNameFilter := ""- if namespace == lastNamespace {+ if namespace == continuationNamespace {tableNameFilter = startTableName}@@ -480,6 +488,11 @@ func (h *S3TablesHandler) listTablesInAllNamespaces(ctx context.Context, filerClcontinue}+ // Clear startTableName after the first matching namespace is processed+ if namespace == continuationNamespace {+ startTableName = ""+ }+if len(*tables) >= maxTables {return nil}