mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
mq broker: pass the table catalog's answers through the filer accessor
The filer accessor treats any error as a failed filer: it records the failure, asks the next filer and wraps the last error with %v. A catalog answer such as NoSuchTable then reached ConfigureTopic as an opaque string, so a missing table was reported instead of created. The catalog now goes through an adapter that returns the catalog's own answers unwrapped and leaves failover to real filer failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e579e28d94
commit
e028229694
3 files changed
+46
-1
No files matched your search
@@ -134,7 +134,7 @@ func NewMessageBroker(option *MessageQueueBrokerOption, grpcDialOption grpc.Dial
|
||||
},
|
||||
}
|
||||
mqBroker.fca = fca
|
||||
mqBroker.topicTables = icebergcatalog.NewServer(fca, nil)
|
||||
mqBroker.topicTables = icebergcatalog.NewServer(topicTableFilers{fca}, nil)
|
||||
subCoordinator.FilerClientAccessor = fca
|
||||
|
||||
mqBroker.MasterClient.SetOnPeerUpdateFn(mqBroker.OnBrokerUpdate)
|
||||
|
||||
@@ -7,9 +7,11 @@ import (
|
||||
|
||||
"github.com/apache/iceberg-go"
|
||||
"github.com/apache/iceberg-go/table"
|
||||
"github.com/seaweedfs/seaweedfs/weed/filer_client"
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
"github.com/seaweedfs/seaweedfs/weed/mq/topic"
|
||||
"github.com/seaweedfs/seaweedfs/weed/mq/topictable"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/schema_pb"
|
||||
icebergcatalog "github.com/seaweedfs/seaweedfs/weed/s3api/iceberg"
|
||||
@@ -18,6 +20,29 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// topicTableFilers hands the table catalog the broker's filers. An answer the
|
||||
// catalog gave is returned as is: the accessor would wrap it out of reach of
|
||||
// errors.As, mark the filer failed, and ask every other filer, which would
|
||||
// answer the same.
|
||||
type topicTableFilers struct {
|
||||
fca *filer_client.FilerClientAccessor
|
||||
}
|
||||
|
||||
func (f topicTableFilers) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||
var answer error
|
||||
if err := f.fca.WithFilerClient(streamingMode, func(client filer_pb.SeaweedFilerClient) error {
|
||||
answer = fn(client)
|
||||
var tableErr *s3tables.S3TablesError
|
||||
if errors.As(answer, &tableErr) {
|
||||
return nil
|
||||
}
|
||||
return answer
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
// requestedTopicTable is the table a configure leaves the topic with: an unset
|
||||
// request keeps stored, an empty table bucket ARN detaches it.
|
||||
func requestedTopicTable(requested, stored *mq_pb.TopicTable) *mq_pb.TopicTable {
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/apache/iceberg-go/table"
|
||||
"github.com/seaweedfs/seaweedfs/weed/mq/schema"
|
||||
"github.com/seaweedfs/seaweedfs/weed/mq/topictable"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/schema_pb"
|
||||
icebergcatalog "github.com/seaweedfs/seaweedfs/weed/s3api/iceberg"
|
||||
@@ -356,3 +357,22 @@ func TestTopicLeavesAnEmptyTable(t *testing.T) {
|
||||
t.Fatalf("detached topic still names %v", stored)
|
||||
}
|
||||
}
|
||||
|
||||
// The catalog sees its own answers through the broker's filers unwrapped,
|
||||
// while a failure to reach a filer still fails the call.
|
||||
func TestTopicTableFilersPassTheCatalogsAnswer(t *testing.T) {
|
||||
_, b := newFencingFiler(t)
|
||||
filers := topicTableFilers{b.fca}
|
||||
calls := 0
|
||||
err := filers.WithFilerClient(false, func(filer_pb.SeaweedFilerClient) error {
|
||||
calls++
|
||||
return &s3tables.S3TablesError{Type: s3tables.ErrCodeNoSuchTable, Message: "table events not found"}
|
||||
})
|
||||
if !isNoSuchTable(err) || calls != 1 {
|
||||
t.Fatalf("got %v after %d calls, want the catalog's NoSuchTable from one", err, calls)
|
||||
}
|
||||
unreachable := status.Error(codes.Unavailable, "filer down")
|
||||
if err := filers.WithFilerClient(false, func(filer_pb.SeaweedFilerClient) error { return unreachable }); err == nil || isNoSuchTable(err) {
|
||||
t.Fatalf("got %v, want the filer failure", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user