diff --git a/weed/mq/README.md b/weed/mq/README.md index a3d1a36443..a22c7d5aec 100644 --- a/weed/mq/README.md +++ b/weed/mq/README.md @@ -57,8 +57,11 @@ A partition's files are written only by the broker holding the partition's fence leadership cannot add to them. When that broker fails, the partition is assigned to another broker, which takes the fence at a new epoch and continues from the files. -A follower keeps the messages it receives in memory and does not write them. Until followers can take over a failed -broker's partition, messages it acknowledged but had not flushed yet are lost when it fails. +Each partition has a leader and a follower on two brokers. The leader acknowledges a message once the follower holds +it, and the follower keeps what the leader has not flushed yet in memory. If either is lost, the survivor writes what +it holds, seals the fence and reports the generation ended; the balancer then assigns a new pair at the next epoch, +and publishers resend what was not acknowledged. A partition placed while only one broker is live has no follower, +and messages it acknowledged but had not flushed yet are lost when that broker fails. ## Auto Split or Merge diff --git a/weed/mq/broker/broker_errors.go b/weed/mq/broker/broker_errors.go index 02d1f65f63..c27b543973 100644 --- a/weed/mq/broker/broker_errors.go +++ b/weed/mq/broker/broker_errors.go @@ -26,6 +26,8 @@ const ( BrokerErrorPublisherNotFound int32 = 100 BrokerErrorConnectionFailed int32 = 101 BrokerErrorFollowerConnectionFailed int32 = 102 + // the partition's leader/follower pair broke; publishers look it up again and resend + BrokerErrorGenerationEnded int32 = 103 ) // BrokerErrorInfo contains metadata about a broker error @@ -106,6 +108,10 @@ var BrokerErrors = map[int32]BrokerErrorInfo{ Code: BrokerErrorConnectionFailed, Name: "CONNECTION_FAILED", Description: "Connection failed", KafkaCode: 13, // NETWORK_EXCEPTION }, + BrokerErrorGenerationEnded: { + Code: BrokerErrorGenerationEnded, Name: "GENERATION_ENDED", + Description: "Partition generation ended; look up its new leader", KafkaCode: 6, + }, BrokerErrorFollowerConnectionFailed: { Code: BrokerErrorFollowerConnectionFailed, Name: "FOLLOWER_CONNECTION_FAILED", Description: "Failed to connect to follower brokers", KafkaCode: 13, // NETWORK_EXCEPTION diff --git a/weed/mq/broker/broker_grpc_assign.go b/weed/mq/broker/broker_grpc_assign.go index 61f256156f..93a44191a1 100644 --- a/weed/mq/broker/broker_grpc_assign.go +++ b/weed/mq/broker/broker_grpc_assign.go @@ -46,8 +46,10 @@ func (b *MessageQueueBroker) AssignTopicPartitions(c context.Context, request *m b.accessLock.Unlock() return nil, status.Errorf(codes.Unavailable, "broker %s is stopping", b.option.BrokerAddress()) } - if localPartition == nil { - localPartition, genErr := b.newLeaderPartition(t, partition, assignment.Epoch) + // a follower learns of its partition from the leader's follow stream + isLeader := assignment.LeaderBroker == "" || pb.ServerAddress(assignment.LeaderBroker).Equals(b.option.BrokerAddress()) + if isLeader && localPartition == nil { + localPartition, genErr := b.newLeaderPartition(t, partition, assignment) if genErr != nil { b.accessLock.Unlock() return nil, status.Errorf(codes.Unavailable, "%v", genErr) @@ -57,26 +59,12 @@ func (b *MessageQueueBroker) AssignTopicPartitions(c context.Context, request *m b.accessLock.Unlock() return nil, status.Errorf(codes.Unavailable, "broker %s is stopping", b.option.BrokerAddress()) } + go b.watchReplica(t, partition, localPartition, assignment.Epoch) } } b.accessLock.Unlock() } - // if is leader, notify the followers to drain existing topic partition subscriptions - if request.IsLeader { - for _, brokerPartition := range request.BrokerPartitionAssignments { - if follower := brokerPartition.FollowerBroker; follower != "" { - err := pb.WithBrokerGrpcClient(false, follower, b.grpcDialOption, func(client mq_pb.SeaweedMessagingClient) error { - _, err := client.AssignTopicPartitions(context.Background(), request) - return err - }) - if err != nil { - return ret, err - } - } - } - } - return ret, nil } @@ -91,15 +79,10 @@ func (b *MessageQueueBroker) assignTopicPartitionsToBrokers(ctx context.Context, defer wg.Done() if doCreateErr := b.withBrokerClient(false, pb.ServerAddress(bpa.LeaderBroker), func(client mq_pb.SeaweedMessagingClient) error { _, doCreateErr := client.AssignTopicPartitions(ctx, &mq_pb.AssignTopicPartitionsRequest{ - Topic: t, - BrokerPartitionAssignments: []*mq_pb.BrokerPartitionAssignment{ - { - Partition: bpa.Partition, - Epoch: bpa.Epoch, - }, - }, - IsLeader: true, - IsDraining: !isAdd, + Topic: t, + BrokerPartitionAssignments: []*mq_pb.BrokerPartitionAssignment{bpa}, + IsLeader: true, + IsDraining: !isAdd, }) if doCreateErr != nil { if !isAdd { diff --git a/weed/mq/broker/broker_grpc_configure.go b/weed/mq/broker/broker_grpc_configure.go index 4b22a3e5e5..a7c3f78da8 100644 --- a/weed/mq/broker/broker_grpc_configure.go +++ b/weed/mq/broker/broker_grpc_configure.go @@ -36,6 +36,8 @@ func (b *MessageQueueBroker) ConfigureTopic(ctx context.Context, request *mq_pb. } } + b.topicConfLock.Lock() + defer b.topicConfLock.Unlock() t := topic.FromPbTopic(request.Topic) var readErr, assignErr error resp, readErr = b.fca.ReadTopicConfFromFiler(t) diff --git a/weed/mq/broker/broker_grpc_generation.go b/weed/mq/broker/broker_grpc_generation.go new file mode 100644 index 0000000000..806914cd38 --- /dev/null +++ b/weed/mq/broker/broker_grpc_generation.go @@ -0,0 +1,126 @@ +package broker + +import ( + "context" + "errors" + "fmt" + "time" + + "github.com/seaweedfs/seaweedfs/weed/glog" + "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer" + "github.com/seaweedfs/seaweedfs/weed/mq/topic" + "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// EndPartitionGeneration gives a partition whose leader/follower pair broke a new +// pair. A report for an epoch that already moved on is ignored, so both halves of +// a broken pair can report it. +func (b *MessageQueueBroker) EndPartitionGeneration(ctx context.Context, req *mq_pb.EndPartitionGenerationRequest) (resp *mq_pb.EndPartitionGenerationResponse, err error) { + if !b.isLockOwner() { + err = b.withBalancerClient(func(client mq_pb.SeaweedMessagingClient) error { + resp, err = client.EndPartitionGeneration(ctx, req) + return err + }) + return resp, err + } + + if !b.balancerSettled() { + // a new pair is picked from the brokers it has heard from, so wait until all have reconnected + return nil, status.Error(codes.Unavailable, "broker balancer is still settling") + } + b.topicConfLock.Lock() + defer b.topicConfLock.Unlock() + t := topic.FromPbTopic(req.Topic) + conf, err := b.fca.ReadTopicConfFromFiler(t) + if err != nil { + return nil, fmt.Errorf("read topic %s: %w", t, err) + } + for _, assignment := range conf.BrokerPartitionAssignments { + if !b.partitionsMatch(assignment.Partition, req.Partition) { + continue + } + if assignment.Epoch != req.Epoch { + return &mq_pb.EndPartitionGenerationResponse{}, nil + } + previousLeader, previousFollower := assignment.LeaderBroker, assignment.FollowerBroker + pub_balancer.ReassignPartition(b.PubBalancer.Brokers, assignment) + if err := b.fca.SaveTopicConfToFiler(t, conf); err != nil { + return nil, fmt.Errorf("save topic %s: %w", t, err) + } + b.invalidateTopicCache(t) + glog.V(0).Infof("topic %s partition %v epoch %d ended (reported by %s): %s/%s -> %s/%s at epoch %d", t, topic.FromPbPartition(req.Partition), req.Epoch, req.Broker, + previousLeader, previousFollower, assignment.LeaderBroker, assignment.FollowerBroker, assignment.Epoch) + return &mq_pb.EndPartitionGenerationResponse{}, nil + } + return nil, status.Errorf(codes.NotFound, "topic %s has no partition %v", t, topic.FromPbPartition(req.Partition)) +} + +// watchReplica ends this leader's generation when its follower is lost. It starts +// once lp is registered, so the generation never ends under an unlisted partition. +func (b *MessageQueueBroker) watchReplica(t topic.Topic, p topic.Partition, lp *topic.LocalPartition, epoch int64) { + if lp.Replica == nil { + return + } + <-lp.Replica.Broken() + if err := lp.Replica.Err(); errors.Is(err, topic.ErrReplicaClosed) || errors.Is(err, topic.ErrReplicaAbandoned) { + return + } + glog.Warningf("topic %s partition %v epoch %d lost follower %s: %v", t, p, epoch, lp.Follower, lp.Replica.Err()) + b.endLeaderGeneration(t, lp, epoch) +} + +// endLeaderGeneration stores what this leader holds, seals its fence and reports +// the generation ended. The fence is kept renewed meanwhile, so a new leader waits. +func (b *MessageQueueBroker) endLeaderGeneration(t topic.Topic, lp *topic.LocalPartition, epoch int64) { + ctx := context.Background() + p, fence := lp.Partition, lp.Fence + stopRenewing := b.keepFenceRenewed(fence) + b.localTopicManager.RemoveLocalPartition(t, lp) + b.localTopicManager.WaitRetired(ctx, t, p) + stopRenewing() + b.sealAndReportGeneration(ctx, t, p, fence, epoch) +} + +func (b *MessageQueueBroker) sealAndReportGeneration(ctx context.Context, t topic.Topic, p topic.Partition, fence *topic.PartitionFence, epoch int64) { + if fence != nil && !fence.IsLost() { + if err := b.renewPartitionFence(ctx, fence, true); err != nil { + glog.Warningf("seal topic %s partition %v epoch %d: %v", t, p, epoch, err) + } + } + go b.reportGenerationEnded(t, p, epoch) +} + +const generationReportTimeout = 30 * time.Second + +// reportGenerationEnded retries until a balancer takes the report: the lost broker +// may have been the balancer, and the partition stays unserved until one does. +func (b *MessageQueueBroker) reportGenerationEnded(t topic.Topic, p topic.Partition, epoch int64) { + req := &mq_pb.EndPartitionGenerationRequest{ + Topic: t.ToPbTopic(), + Partition: p.ToPbPartition(), + Epoch: epoch, + Broker: string(b.option.BrokerAddress()), + } + parent := context.Background() + if b.ctx != nil { + parent = b.ctx + } + for wait := time.Second; ; wait = min(2*wait, 10*time.Second) { + // a balancer that stops answering must not hold the retries; a repeat after a + // save that landed finds the epoch moved on and returns without writing + ctx, cancel := context.WithTimeout(parent, generationReportTimeout) + _, err := b.EndPartitionGeneration(ctx, req) + cancel() + if err == nil { + return + } + glog.Warningf("report topic %s partition %v epoch %d ended: %v", t, p, epoch, err) + select { + case <-parent.Done(): + return + case <-time.After(wait): + } + } +} diff --git a/weed/mq/broker/broker_grpc_lookup.go b/weed/mq/broker/broker_grpc_lookup.go index 7e67ad4163..d2afaf0f7f 100644 --- a/weed/mq/broker/broker_grpc_lookup.go +++ b/weed/mq/broker/broker_grpc_lookup.go @@ -289,6 +289,8 @@ func (b *MessageQueueBroker) GetTopicConfiguration(ctx context.Context, request var conf *mq_pb.ConfigureTopicResponse var createdAtNs, modifiedAtNs int64 + b.topicConfLock.Lock() + defer b.topicConfLock.Unlock() if conf, createdAtNs, modifiedAtNs, err = b.fca.ReadTopicConfFromFilerWithMetadata(t); err != nil { glog.V(0).Infof("get topic configuration %s: %v", request.Topic, err) return nil, fmt.Errorf("failed to read topic configuration: %w", err) diff --git a/weed/mq/broker/broker_grpc_pub.go b/weed/mq/broker/broker_grpc_pub.go index 08711b303c..da64352d94 100644 --- a/weed/mq/broker/broker_grpc_pub.go +++ b/weed/mq/broker/broker_grpc_pub.go @@ -7,8 +7,6 @@ import ( "io" "math/rand/v2" "net" - "sync/atomic" - "time" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/mq/topic" @@ -72,10 +70,19 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis // get or generate a local partition t, p := topic.FromPbTopic(initMessage.Topic), topic.FromPbPartition(initMessage.Partition) localTopicPartition, getOrGenErr := b.GetOrGenerateLocalPartition(t, p) + if localTopicPartition == nil && (getOrGenErr == nil || errors.Is(getOrGenErr, errFenceLost)) { + // the balancer named this broker from a newer topic.conf than the cached one + b.invalidateTopicCache(t) + localTopicPartition, getOrGenErr = b.GetOrGenerateLocalPartition(t, p) + } if errors.Is(getOrGenErr, errFenceLost) { response.ErrorCode, response.Error = CreateBrokerError(BrokerErrorNotLeaderOrFollower, getOrGenErr.Error()) return stream.Send(response) } + if errors.Is(getOrGenErr, errGenerationEnded) { + response.ErrorCode, response.Error = CreateBrokerError(BrokerErrorGenerationEnded, getOrGenErr.Error()) + return stream.Send(response) + } if getOrGenErr != nil { response.ErrorCode, response.Error = CreateBrokerError(BrokerErrorTopicNotFound, fmt.Sprintf("topic %v not found: %v", t, getOrGenErr)) glog.Errorf("topic %v not found: %v", t, getOrGenErr) @@ -90,11 +97,8 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis response.ErrorCode, response.Error = CreateBrokerError(BrokerErrorNotLeaderOrFollower, fmt.Sprintf("topic %v partition %v is fenced by another broker", t, p)) return stream.Send(response) } - - // connect to follower brokers - if followerErr := localTopicPartition.MaybeConnectToFollowers(initMessage, b.grpcDialOption); followerErr != nil { - response.ErrorCode, response.Error = CreateBrokerError(BrokerErrorFollowerConnectionFailed, followerErr.Error()) - glog.Errorf("MaybeConnectToFollowers: %v", followerErr) + if replica := localTopicPartition.Replica; replica != nil && replica.Err() != nil { + response.ErrorCode, response.Error = CreateBrokerError(BrokerErrorGenerationEnded, fmt.Sprintf("topic %v partition %v: %v", t, p, replica.Err())) return stream.Send(response) } @@ -103,43 +107,6 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis publisher := topic.NewLocalPublisher() localTopicPartition.Publishers.AddPublisher(clientName, publisher) - // DISABLED: Periodic ack goroutine not needed with immediate per-message acks - // Immediate acks provide correct offset information for Kafka Gateway - var receivedSequence, acknowledgedSequence int64 - var isClosed bool - - if false { - ackInterval := int64(1) - if initMessage.AckInterval > 0 { - ackInterval = int64(initMessage.AckInterval) - } - go func() { - defer func() { - // println("stop sending ack to publisher", initMessage.PublisherName) - }() - - lastAckTime := time.Now() - for !isClosed { - receivedSequence = atomic.LoadInt64(&localTopicPartition.AckTsNs) - if acknowledgedSequence < receivedSequence && (receivedSequence-acknowledgedSequence >= ackInterval || time.Since(lastAckTime) > 100*time.Millisecond) { - acknowledgedSequence = receivedSequence - response := &mq_pb.PublishMessageResponse{ - AckTsNs: acknowledgedSequence, - } - if err := stream.Send(response); err != nil { - glog.Errorf("Error sending response %v: %v", response, err) - } - // Update acknowledged offset for this publisher - publisher.UpdateAckedOffset(acknowledgedSequence) - // println("sent ack", acknowledgedSequence, "=>", initMessage.PublisherName) - lastAckTime = time.Now() - } else { - time.Sleep(10 * time.Millisecond) // Reduced from 1s to 10ms for faster acknowledgments - } - } - }() - } - defer func() { // remove the publisher localTopicPartition.Publishers.RemovePublisher(clientName) @@ -153,10 +120,6 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis // send a hello message stream.Send(&mq_pb.PublishMessageResponse{}) - defer func() { - isClosed = true - }() - // process each published messages for { // receive a message @@ -199,6 +162,16 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis } assignedOffset, err := localTopicPartition.PublishWithOffset(dataMessage) + if replica := localTopicPartition.Replica; replica != nil { + // acked only once the follower holds it too + if err == nil { + err = replica.WaitAcked(assignedOffset) + } + if replicaErr := replica.Err(); replicaErr != nil { + response.ErrorCode, response.Error = CreateBrokerError(BrokerErrorGenerationEnded, fmt.Sprintf("topic %v partition %v: %v", t, p, replicaErr)) + return stream.Send(response) + } + } if err != nil { return fmt.Errorf("topic %v partition %v publish error: %w", initMessage.Topic, initMessage.Partition, err) } diff --git a/weed/mq/broker/broker_grpc_pub_follow.go b/weed/mq/broker/broker_grpc_pub_follow.go index 5ce9dd8323..48d7e8b207 100644 --- a/weed/mq/broker/broker_grpc_pub_follow.go +++ b/weed/mq/broker/broker_grpc_pub_follow.go @@ -2,150 +2,115 @@ package broker import ( "context" + "encoding/binary" "fmt" - "io" + "sort" "time" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/mq/topic" + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" - "github.com/seaweedfs/seaweedfs/weed/util/buffered_queue" - "github.com/seaweedfs/seaweedfs/weed/util/log_buffer" ) -type memBuffer struct { - buf []byte - startTime time.Time - stopTime time.Time -} - -func (b *MessageQueueBroker) PublishFollowMe(stream mq_pb.SeaweedMessaging_PublishFollowMeServer) (err error) { - var req *mq_pb.PublishFollowMeRequest - req, err = stream.Recv() +// PublishFollowMe holds a leader's entries that are not stored yet, acking each, +// until the leader closes the stream after storing everything. +func (b *MessageQueueBroker) PublishFollowMe(stream mq_pb.SeaweedMessaging_PublishFollowMeServer) error { + req, err := stream.Recv() if err != nil { return err } - initMessage := req.GetInit() - if initMessage == nil { + init := req.GetInit() + if init == nil { return fmt.Errorf("missing init message") } + t, p := topic.FromPbTopic(init.Topic), topic.FromPbPartition(init.Partition) - // create an in-memory queue of buffered messages - inMemoryBuffers := buffered_queue.NewBufferedQueue[memBuffer](4) - logBuffer := b.buildFollowerLogBuffer(inMemoryBuffers) - - lastFlushTsNs := time.Now().UnixNano() - - // follow each published messages + var held []*filer_pb.LogEntry + acked := int64(-1) for { - // receive a message - req, err = stream.Recv() + req, err := stream.Recv() if err != nil { - if err == io.EOF { - err = nil - break - } - glog.V(0).Infof("topic %v partition %v publish stream error: %v", initMessage.Topic, initMessage.Partition, err) - break + // the leader went without closing the stream, so it may not have stored these + glog.Warningf("follow stream of %v %v from %s at epoch %d broke with %d unstored entries: %v", t, p, init.Leader, init.Epoch, len(held), err) + b.takeOverPartition(t, p, init, held) + return nil } - - // Process the received message - if dataMessage := req.GetData(); dataMessage != nil { - - // TODO: change this to DataMessage - // log the message - if addErr := logBuffer.AddToBuffer(dataMessage); addErr != nil { - err = fmt.Errorf("failed to add message to log buffer: %w", addErr) - glog.Errorf("Failed to add message to log buffer: %v", addErr) - break - } - - // send back the ack - if err := stream.Send(&mq_pb.PublishFollowMeResponse{ - AckTsNs: dataMessage.TsNs, - }); err != nil { - glog.Errorf("Error sending response %v: %v", dataMessage, err) - } - // println("ack", string(dataMessage.Key), dataMessage.TsNs) - } else if closeMessage := req.GetClose(); closeMessage != nil { - glog.V(0).Infof("topic %v partition %v publish stream closed: %v", initMessage.Topic, initMessage.Partition, closeMessage) - break - } else if flushMessage := req.GetFlush(); flushMessage != nil { - glog.V(0).Infof("topic %v partition %v publish stream flushed: %v", initMessage.Topic, initMessage.Partition, flushMessage) - - lastFlushTsNs = flushMessage.TsNs - - // drop already flushed messages - for mem, found := inMemoryBuffers.PeekHead(); found; mem, found = inMemoryBuffers.PeekHead() { - if mem.stopTime.UnixNano() <= flushMessage.TsNs { - inMemoryBuffers.Dequeue() - // println("dropping flushed messages: ", mem.startTime.UnixNano(), mem.stopTime.UnixNano(), len(mem.buf)) - } else { - break - } - } - - } else { - glog.Errorf("unknown message: %v", req) - } - } - - t, p := topic.FromPbTopic(initMessage.Topic), topic.FromPbPartition(initMessage.Partition) - - logBuffer.ShutdownLogBuffer() - // wait until all messages are sent to inMemoryBuffers - for !logBuffer.IsAllFlushed() { - time.Sleep(113 * time.Millisecond) - } - - partitionDir := topic.PartitionDir(t, p) - - // flush the remaining messages - inMemoryBuffers.CloseInput() - for mem, found := inMemoryBuffers.Dequeue(); found; mem, found = inMemoryBuffers.Dequeue() { - if len(mem.buf) == 0 { + switch m := req.Message.(type) { + case *mq_pb.PublishFollowMeRequest_Entry: + held = append(held, m.Entry) + acked = m.Entry.Offset + case *mq_pb.PublishFollowMeRequest_Heartbeat: + case *mq_pb.PublishFollowMeRequest_Flush: + held = dropStored(held, m.Flush.Offset) + continue + case *mq_pb.PublishFollowMeRequest_Close: + return nil + default: continue } - - startTime, stopTime := mem.startTime.UTC(), mem.stopTime.UTC() - - if stopTime.UnixNano() <= lastFlushTsNs { - glog.V(0).Infof("dropping remaining data at %v %v", t, p) - continue + if err := stream.Send(&mq_pb.PublishFollowMeResponse{AckOffset: acked}); err != nil { + glog.Warningf("follow stream of %v %v from %s at epoch %d failed to ack with %d unstored entries: %v", t, p, init.Leader, init.Epoch, len(held), err) + b.takeOverPartition(t, p, init, held) + return nil } - - // TODO trim data earlier than lastFlushTsNs - - targetFile := fmt.Sprintf("%s/%s", partitionDir, topic.LogFileName(startTime, 0)) - - // A follower holds no fence, so the fenced writer refuses its copy. - if err := b.writeLogFile(context.Background(), nil, targetFile, mem.buf); err != nil { - glog.Warningf("dropping remaining data at %v %v size %d: %v", t, p, len(mem.buf), err) - continue - } - - glog.V(0).Infof("flushed remaining data at %v to %s size %d", mem.stopTime.UnixNano(), targetFile, len(mem.buf)) } - - glog.V(0).Infof("shut down follower for %v %v", t, p) - - return err } -func (b *MessageQueueBroker) buildFollowerLogBuffer(inMemoryBuffers *buffered_queue.BufferedQueue[memBuffer]) *log_buffer.LogBuffer { - lb := log_buffer.NewLogBuffer("follower", - 5*time.Second, func(logBuffer *log_buffer.LogBuffer, startTime, stopTime time.Time, buf []byte, minOffset, maxOffset int64) { - if len(buf) == 0 { +// dropStored keeps the entries above offset; held is in offset order. +func dropStored(held []*filer_pb.LogEntry, offset int64) []*filer_pb.LogEntry { + i := sort.Search(len(held), func(i int) bool { return held[i].Offset > offset }) + return append([]*filer_pb.LogEntry(nil), held[i:]...) +} + +// takeOverPartition moves the fence from a lost leader to this follower, stores the +// entries the leader had not, and ends the generation. Every acked entry is here, +// since the leader acks only what this follower holds. +func (b *MessageQueueBroker) takeOverPartition(t topic.Topic, p topic.Partition, init *mq_pb.PublishFollowMeRequest_InitMessage, held []*filer_pb.LogEntry) { + ctx := context.Background() + if b.ctx != nil { + ctx = b.ctx + } + // these entries may be the only copy left, so a filer error is retried until the fence moves on + var fence *topic.PartitionFence + if err := retryLogWrite(ctx, topic.PartitionFencePath(t, p), func() (err error) { + fence, err = b.takeOverPartitionFence(ctx, t, p, init.Epoch, init.Leader) + return err + }); err != nil { + glog.V(0).Infof("not taking over %v %v epoch %d: %v", t, p, init.Epoch, err) + return + } + stopRenewing := b.keepFenceRenewed(fence) + defer stopRenewing() + // with the fence moved, nothing else adds to what is stored + var highWaterMark int64 + if err := retryLogWrite(ctx, topic.PartitionDir(t, p), func() (err error) { + _, highWaterMark, err = b.getOffsetRangeFromChunkMetadata(t, p) + return err + }); err != nil { + glog.Errorf("take over %v %v epoch %d: %v", t, p, init.Epoch, err) + return + } + held = dropStored(held, highWaterMark-1) + if len(held) > 0 { + var data []byte + for _, entry := range held { + encoded, err := entry.MarshalVT() + if err != nil { + glog.Errorf("take over %v %v epoch %d: %v", t, p, init.Epoch, err) return } - inMemoryBuffers.Enqueue(memBuffer{ - // The flush callback borrows buf only until it returns. - buf: append([]byte(nil), buf...), - startTime: startTime, - stopTime: stopTime, - }) - glog.V(0).Infof("queue up %d~%d size %d", startTime.UnixNano(), stopTime.UnixNano(), len(buf)) - }, nil, func() { - }) - return lb + data = binary.BigEndian.AppendUint32(data, uint32(len(encoded))) + data = append(data, encoded...) + } + first, last := held[0], held[len(held)-1] + targetFile := topic.PartitionDir(t, p) + "/" + topic.LogFileName(time.Unix(0, first.TsNs), first.Offset) + if err := b.writeLogFile(ctx, fence, targetFile, data, first.Offset, last.Offset); err != nil { + glog.Errorf("take over %v %v epoch %d: store offsets %d-%d: %v", t, p, init.Epoch, first.Offset, last.Offset, err) + return + } + } + glog.V(0).Infof("took over %v %v epoch %d from %s, stored %d entries", t, p, init.Epoch, init.Leader, len(held)) + stopRenewing() + b.sealAndReportGeneration(ctx, t, p, fence, init.Epoch) } diff --git a/weed/mq/broker/broker_grpc_pub_follow_buffer_test.go b/weed/mq/broker/broker_grpc_pub_follow_buffer_test.go deleted file mode 100644 index 1460aec8e3..0000000000 --- a/weed/mq/broker/broker_grpc_pub_follow_buffer_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package broker - -import ( - "bytes" - "encoding/binary" - "fmt" - "testing" - - "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" - "github.com/seaweedfs/seaweedfs/weed/util/buffered_queue" -) - -// Keep the first flushed batch queued while subsequent flushes can reuse the -// log buffer's pooled storage. -func TestFollowerQueuedBufferRetainsBytes(t *testing.T) { - queue := buffered_queue.NewBufferedQueue[memBuffer](4) - broker := &MessageQueueBroker{} - lb := broker.buildFollowerLogBuffer(queue) - defer func() { lb.ShutdownLogBuffer(); lb.WaitForShutdown(); queue.CloseInput() }() - if err := lb.InitializeOffsetFromExistingData(func() (int64, error) { return 99, nil }); err != nil { - t.Fatal(err) - } - want := bytes.Repeat([]byte{'A'}, 64) - var original []byte - for i := 0; i < 8; i++ { - data := bytes.Repeat([]byte{byte('A' + i)}, 64) - if err := lb.AddDataToBuffer([]byte("key"), data, 1_000_000_000+int64(i)*100_000_000); err != nil { - t.Fatal(err) - } - lb.ForceFlush() - first, ok := queue.PeekHead() - if !ok { - t.Fatal("completed flush did not queue follower data") - } - if i == 0 { - original = bytes.Clone(first.buf) - } - if !bytes.Equal(first.buf, original) { - var entry filer_pb.LogEntry - var decodeErr error - if len(first.buf) < 4 { - decodeErr = fmt.Errorf("short header") - } else { - size := int(binary.BigEndian.Uint32(first.buf[:4])) - if size+4 > len(first.buf) { - decodeErr = fmt.Errorf("truncated frame: announced=%d slice=%d", size, len(first.buf)) - } else { - decodeErr = entry.UnmarshalVT(first.buf[4 : 4+size]) - } - } - t.Fatalf("queued first buffer changed after later flush %d: want_data=%q actual_data=%q decode_error=%v first_offset=%d", i, want, entry.Data, decodeErr, entry.Offset) - } - } -} diff --git a/weed/mq/broker/broker_grpc_sub.go b/weed/mq/broker/broker_grpc_sub.go index b388d083c7..6905fcdc4e 100644 --- a/weed/mq/broker/broker_grpc_sub.go +++ b/weed/mq/broker/broker_grpc_sub.go @@ -9,7 +9,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/mq/sub_coordinator" "github.com/seaweedfs/seaweedfs/weed/mq/topic" - "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" @@ -72,41 +71,6 @@ func (b *MessageQueueBroker) SubscribeMessage(stream mq_pb.SeaweedMessaging_Subs } }() - // connect to the follower - var subscribeFollowMeStream mq_pb.SeaweedMessaging_SubscribeFollowMeClient - glog.V(0).Infof("follower broker: %v", req.GetInit().FollowerBroker) - if req.GetInit().FollowerBroker != "" { - follower := req.GetInit().FollowerBroker - if followerGrpcConnection, err := pb.GrpcDial(ctx, follower, true, b.grpcDialOption); err != nil { - return fmt.Errorf("fail to dial %s: %v", follower, err) - } else { - defer func() { - println("closing SubscribeFollowMe connection", follower) - if subscribeFollowMeStream != nil { - subscribeFollowMeStream.CloseSend() - } - // followerGrpcConnection.Close() - }() - followerClient := mq_pb.NewSeaweedMessagingClient(followerGrpcConnection) - if subscribeFollowMeStream, err = followerClient.SubscribeFollowMe(ctx); err != nil { - return fmt.Errorf("fail to subscribe to %s: %v", follower, err) - } else { - if err := subscribeFollowMeStream.Send(&mq_pb.SubscribeFollowMeRequest{ - Message: &mq_pb.SubscribeFollowMeRequest_Init{ - Init: &mq_pb.SubscribeFollowMeRequest_InitMessage{ - Topic: req.GetInit().Topic, - Partition: req.GetInit().GetPartitionOffset().Partition, - ConsumerGroup: req.GetInit().ConsumerGroup, - }, - }, - }); err != nil { - return fmt.Errorf("fail to send init to %s: %v", follower, err) - } - } - } - glog.V(0).Infof("follower %s connected", follower) - } - // Channel to handle seek requests - signals Subscribe loop to restart from new offset seekChan := make(chan *mq_pb.SubscribeMessageRequest_SeekMessage, 1) @@ -162,19 +126,8 @@ func (b *MessageQueueBroker) SubscribeMessage(stream mq_pb.SeaweedMessaging_Subs // Update acknowledged offset and last seen time for this subscriber when it sends an ack subscriber.UpdateAckedOffset(currentLastOffset) // fmt.Printf("%+v recv (%s,%d), oldest %d\n", partition, string(ack.GetAck().Key), ack.GetAck().TsNs, currentLastOffset) - if subscribeFollowMeStream != nil && currentLastOffset > lastOffset { - if err := subscribeFollowMeStream.Send(&mq_pb.SubscribeFollowMeRequest{ - Message: &mq_pb.SubscribeFollowMeRequest_Ack{ - Ack: &mq_pb.SubscribeFollowMeRequest_AckMessage{ - TsNs: currentLastOffset, - }, - }, - }); err != nil { - glog.Errorf("Error sending ack to follower: %v", err) - break - } + if currentLastOffset > lastOffset { lastOffset = currentLastOffset - // fmt.Printf("%+v forwarding ack %d\n", partition, lastOffset) } } if lastOffset > 0 { @@ -183,17 +136,6 @@ func (b *MessageQueueBroker) SubscribeMessage(stream mq_pb.SeaweedMessaging_Subs glog.Errorf("saveConsumerGroupOffset partition %v lastOffset %d: %v", partition, lastOffset, err) } } - if subscribeFollowMeStream != nil { - if err := subscribeFollowMeStream.Send(&mq_pb.SubscribeFollowMeRequest{ - Message: &mq_pb.SubscribeFollowMeRequest_Close{ - Close: &mq_pb.SubscribeFollowMeRequest_CloseMessage{}, - }, - }); err != nil { - if err != io.EOF { - glog.Errorf("Error sending close to follower: %v", err) - } - } - } }() // Create a goroutine to handle context cancellation and wake up the condition variable diff --git a/weed/mq/broker/broker_partition_fence.go b/weed/mq/broker/broker_partition_fence.go index 26cf3eafea..524295a7fe 100644 --- a/weed/mq/broker/broker_partition_fence.go +++ b/weed/mq/broker/broker_partition_fence.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "strconv" + "sync" "time" "github.com/google/uuid" @@ -13,13 +14,16 @@ import ( "github.com/seaweedfs/seaweedfs/weed/mq" "github.com/seaweedfs/seaweedfs/weed/mq/logstore" "github.com/seaweedfs/seaweedfs/weed/mq/topic" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "github.com/seaweedfs/seaweedfs/weed/util" ) var ( - errFenceLost = errors.New("partition fence is held by another broker") + errFenceLost = errors.New("partition fence is held by another broker") + errGenerationEnded = errors.New("partition generation ended") // the filer recorded this failure under the request id, so a retry of that id replays it errTransactionFailed = errors.New("transaction failed") ) @@ -27,9 +31,11 @@ var ( // fenceTakeTimeout bounds the filer calls a fence take makes while holding accessLock. var fenceTakeTimeout = 10 * time.Second -// newLeaderPartition takes the partition's fence for epoch before anything reads -// the partition's files, so a previous leader can no longer add to them. -func (b *MessageQueueBroker) newLeaderPartition(t topic.Topic, partition topic.Partition, epoch int64) (*topic.LocalPartition, error) { +// newLeaderPartition takes the partition's fence for the assignment's epoch before +// anything reads the partition's files, so a previous leader can no longer add to +// them, then starts replicating to the assigned follower. +func (b *MessageQueueBroker) newLeaderPartition(t topic.Topic, partition topic.Partition, assignment *mq_pb.BrokerPartitionAssignment) (*topic.LocalPartition, error) { + epoch := assignment.Epoch ctx, cancel := context.WithTimeout(context.Background(), fenceTakeTimeout) defer cancel() fence, err := b.takePartitionFence(ctx, t, partition, epoch) @@ -42,6 +48,23 @@ func (b *MessageQueueBroker) newLeaderPartition(t topic.Topic, partition topic.P localPartition.Shutdown() return nil, err } + if follower := assignment.FollowerBroker; follower != "" && !pb.ServerAddress(follower).Equals(b.option.BrokerAddress()) { + replica, err := topic.StartReplicator(follower, b.grpcDialOption, &mq_pb.PublishFollowMeRequest_InitMessage{ + Topic: t.ToPbTopic(), + Partition: assignment.Partition, + Epoch: epoch, + Leader: string(b.option.BrokerAddress()), + }) + if err != nil { + localPartition.Shutdown() + // callers hold accessLock, so the seal gives up and the report goes out regardless + sealCtx, cancelSeal := context.WithTimeout(context.Background(), fenceTakeTimeout) + b.sealAndReportGeneration(sealCtx, t, partition, fence, epoch) + cancelSeal() + return nil, fmt.Errorf("%v: %w", err, errGenerationEnded) + } + localPartition.Replica, localPartition.Follower = replica, follower + } return localPartition, nil } @@ -53,12 +76,15 @@ func fenceEpoch(entry *filer_pb.Entry) (int64, error) { return strconv.ParseInt(string(value), 10, 64) } +// fenceSealWait is how long a new leader leaves an unsealed fence of an earlier +// generation to its holder, which may still be persisting what it holds. +const fenceSealWait = 30 * time.Second + func (b *MessageQueueBroker) takePartitionFence(ctx context.Context, t topic.Topic, partition topic.Partition, epoch int64) (*topic.PartitionFence, error) { - fencePath := util.FullPath(topic.PartitionFencePath(t, partition)) - dir, name := fencePath.DirAndName() + fencePath := topic.PartitionFencePath(t, partition) self := string(b.option.BrokerAddress()) - current, _, _, err := filer_pb.GetEntry(ctx, b, fencePath) + current, _, _, err := filer_pb.GetEntry(ctx, b, util.FullPath(fencePath)) if err != nil && !errors.Is(err, filer_pb.ErrNotFound) { return nil, err } @@ -68,23 +94,119 @@ func (b *MessageQueueBroker) takePartitionFence(ctx context.Context, t topic.Top if parseErr != nil { return nil, fmt.Errorf("fence %s epoch: %w", fencePath, parseErr) } - if storedEpoch > epoch { - return nil, fmt.Errorf("fence %s is at epoch %d held by %s: %w", fencePath, storedEpoch, current.Extended[mq.ExtendedAttrFenceWriter], errFenceLost) + writer, sealed := string(current.Extended[mq.ExtendedAttrFenceWriter]), fenceSealed(current) + switch { + case storedEpoch > epoch: + return nil, fmt.Errorf("fence %s is at epoch %d held by %s: %w", fencePath, storedEpoch, writer, errFenceLost) + case storedEpoch == epoch && (sealed || writer != self): + // this generation ended, or its follower took it over + return nil, fmt.Errorf("fence %s epoch %d held by %s sealed %v: %w", fencePath, epoch, writer, sealed, errFenceLost) + case storedEpoch < epoch && !sealed && time.Since(time.Unix(current.GetAttributes().GetMtime(), 0)) < fenceSealWait: + return nil, fmt.Errorf("fence %s: epoch %d held by %s is still being sealed: %w", fencePath, storedEpoch, writer, errFenceLost) } - if string(current.Extended[mq.ExtendedAttrFenceSealed]) == "true" { - return nil, fmt.Errorf("fence %s is sealed", fencePath) - } - condition = &filer_pb.WriteCondition_Clause{Kind: filer_pb.WriteCondition_IF_ENTRY_EQUAL, ExpectedEntry: current} - if token := current.Extended[s3_constants.ExtETagKey]; len(token) > 0 { - condition = fenceTokenCondition(string(token)) + condition = currentFenceCondition(current) + if storedEpoch < epoch && !sealed { + // judged stale by its mtime, which a renewal changes but the token does not + condition = &filer_pb.WriteCondition_Clause{Kind: filer_pb.WriteCondition_IF_ENTRY_EQUAL, ExpectedEntry: current} } } + fence, err := b.writePartitionFence(ctx, fencePath, condition, epoch, false) + if err != nil { + return nil, err + } + glog.V(0).Infof("broker %s took fence %s at epoch %d", self, fencePath, epoch) + return fence, nil +} - // The token is the fence entry's etag, so writes can require it without reading - // the entry back through a filer that may not have caught up with the owner. +// takeOverPartitionFence moves the fence from a lost leader to this follower within +// the same generation, unless the leader sealed it or someone else moved it first. +func (b *MessageQueueBroker) takeOverPartitionFence(ctx context.Context, t topic.Topic, partition topic.Partition, epoch int64, leader string) (*topic.PartitionFence, error) { + fencePath := topic.PartitionFencePath(t, partition) + current, _, _, err := filer_pb.GetEntry(ctx, b, util.FullPath(fencePath)) + if err != nil { + return nil, err + } + storedEpoch, _ := fenceEpoch(current) + if writer := string(current.Extended[mq.ExtendedAttrFenceWriter]); writer != leader || storedEpoch != epoch || fenceSealed(current) { + return nil, fmt.Errorf("fence %s is held by %s at epoch %d sealed %v: %w", fencePath, writer, storedEpoch, fenceSealed(current), errFenceLost) + } + return b.writePartitionFence(ctx, fencePath, currentFenceCondition(current), epoch, false) +} + +// currentFenceCondition holds while the fence is still current; a fence written +// before tokens is matched as a whole entry. +func currentFenceCondition(current *filer_pb.Entry) *filer_pb.WriteCondition_Clause { + if token := current.Extended[s3_constants.ExtETagKey]; len(token) > 0 { + return fenceTokenCondition(string(token)) + } + return &filer_pb.WriteCondition_Clause{Kind: filer_pb.WriteCondition_IF_ENTRY_EQUAL, ExpectedEntry: current} +} + +// writePartitionFence stores the fence for this broker under a fresh token. The +// token is the entry's etag, so writes can require it without reading the entry +// back through a filer that may not have caught up with the owner. +func (b *MessageQueueBroker) writePartitionFence(ctx context.Context, fencePath string, condition *filer_pb.WriteCondition_Clause, epoch int64, sealed bool) (*topic.PartitionFence, error) { token := uuid.NewString() + if err := b.putFence(ctx, fencePath, condition, epoch, token, sealed); err != nil { + return nil, err + } + return topic.NewPartitionFence(fencePath, epoch, token), nil +} + +// renewPartitionFence refreshes the held fence's mtime, which tells a new leader +// this holder is still persisting. Sealing also replaces the token, so a follower +// that read the fence unsealed cannot take it over afterwards. +func (b *MessageQueueBroker) renewPartitionFence(ctx context.Context, fence *topic.PartitionFence, seal bool) error { + held, token := fence.Token(), fence.Token() + if seal { + token = uuid.NewString() + } + err := b.putFence(ctx, fence.Path, fenceTokenCondition(held), fence.Epoch, token, seal) + if errors.Is(err, errFenceLost) { + fence.MarkLost() + } + if err != nil { + return err + } + fence.Hold(token) + return nil +} + +// fenceRenewInterval keeps a persisting holder's fence well inside fenceSealWait. +var fenceRenewInterval = fenceSealWait / 3 + +// keepFenceRenewed renews fence now and then periodically until stop, so a new +// leader keeps waiting while this broker persists what it holds. +func (b *MessageQueueBroker) keepFenceRenewed(fence *topic.PartitionFence) (stop func()) { + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan struct{}) + go func() { + defer close(done) + for { + if err := b.renewPartitionFence(ctx, fence, false); errors.Is(err, errFenceLost) { + glog.Warningf("fence %s moved on while persisting: %v", fence.Path, err) + return + } + select { + case <-ctx.Done(): + return + case <-time.After(fenceRenewInterval): + } + } + }() + var once sync.Once + return func() { + once.Do(func() { + cancel() + <-done + }) + } +} + +func (b *MessageQueueBroker) putFence(ctx context.Context, fencePath string, condition *filer_pb.WriteCondition_Clause, epoch int64, token string, sealed bool) error { + dir, name := util.FullPath(fencePath).DirAndName() now := time.Now().Unix() - fenceEntry := &filer_pb.Entry{ + entry := &filer_pb.Entry{ Name: name, Attributes: &filer_pb.FuseAttributes{ Crtime: now, @@ -92,20 +214,30 @@ func (b *MessageQueueBroker) takePartitionFence(ctx context.Context, t topic.Top FileMode: uint32(os.FileMode(0644)), }, Extended: map[string][]byte{ - mq.ExtendedAttrFenceWriter: []byte(self), + mq.ExtendedAttrFenceWriter: []byte(b.option.BrokerAddress()), mq.ExtendedAttrFenceEpoch: []byte(strconv.FormatInt(epoch, 10)), s3_constants.ExtETagKey: []byte(token), }, } - if err := b.fencedTransaction(ctx, string(fencePath), condition, uuid.NewString(), &filer_pb.ObjectMutation{ - Type: filer_pb.ObjectMutation_PUT, - Directory: dir, - Entry: fenceEntry, - }); err != nil { - return nil, err + if sealed { + entry.Extended[mq.ExtendedAttrFenceSealed] = []byte("true") } - glog.V(0).Infof("broker %s took fence %s at epoch %d", self, fencePath, epoch) - return &topic.PartitionFence{Path: string(fencePath), Epoch: epoch, Token: token}, nil + mutation := &filer_pb.ObjectMutation{Type: filer_pb.ObjectMutation_PUT, Directory: dir, Entry: entry} + requestId := uuid.NewString() + return retryLogWrite(ctx, fencePath, func() error { + // stamped per attempt, so a renewal that lands late is not already stale; + // a replayed request id answers with the outcome the filer recorded + entry.Attributes.Mtime = time.Now().Unix() + err := b.fencedTransaction(ctx, fencePath, condition, requestId, mutation) + if errors.Is(err, errTransactionFailed) { + requestId = uuid.NewString() + } + return err + }) +} + +func fenceSealed(entry *filer_pb.Entry) bool { + return string(entry.Extended[mq.ExtendedAttrFenceSealed]) == "true" } // retireStaleLeader retires p if it lost its fence or holds it for an older @@ -123,7 +255,16 @@ func (b *MessageQueueBroker) retireStaleLeader(t topic.Topic, p *topic.LocalPart p.LogBuffer.WaitForShutdown() b.accessLock.Lock() // once the broker is stopping, its Shutdown retires p instead - return b.localTopicManager.RemoveLocalPartition(t, p) || b.localTopicManager.GetLocalPartition(t, p.Partition) != p + removed := b.localTopicManager.RemoveLocalPartition(t, p) + if removed && !p.Fence.IsLost() { + // its last flush landed, so the next leader need not wait out fenceSealWait + ctx, cancel := context.WithTimeout(context.Background(), fenceTakeTimeout) + if err := b.renewPartitionFence(ctx, p.Fence, true); err != nil { + glog.V(0).Infof("seal stale fence %s: %v", p.Fence.Path, err) + } + cancel() + } + return removed || b.localTopicManager.GetLocalPartition(t, p.Partition) != p } // fenceTokenCondition holds while the fence entry is still the one written with token. diff --git a/weed/mq/broker/broker_partition_fence_test.go b/weed/mq/broker/broker_partition_fence_test.go index 8fba7a0f4c..175e0abe19 100644 --- a/weed/mq/broker/broker_partition_fence_test.go +++ b/weed/mq/broker/broker_partition_fence_test.go @@ -46,6 +46,8 @@ type fencingFiler struct { lagging map[string]*filer_pb.Entry // lookups wait for their caller to give up, as a stalled filer does stalled bool + // listings fail this many times, as a filer that is briefly unavailable does + failLists int // runs under the lock before a transaction applies, to interleave another writer beforeApply func() volume *httptest.Server @@ -56,6 +58,11 @@ type fencingFiler struct { func (f *fencingFiler) ListEntries(req *filer_pb.ListEntriesRequest, stream filer_pb.SeaweedFiler_ListEntriesServer) error { f.mu.Lock() + if f.failLists > 0 { + f.failLists-- + f.mu.Unlock() + return status.Error(codes.Unavailable, "filer unavailable") + } var names []string children := map[string]*filer_pb.Entry{} for path, entry := range f.entries { @@ -241,8 +248,8 @@ func TestTakeAbsentFenceRequiresItStillAbsent(t *testing.T) { t.Errorf("fence carries %s", key) } } - if fence.Path != path || fence.Token == "" || string(f.entry(path).Extended[s3_constants.ExtETagKey]) != fence.Token { - t.Errorf("held fence token %q is not the stored %v", fence.Token, f.entry(path)) + if fence.Path != path || fence.Token() == "" || string(f.entry(path).Extended[s3_constants.ExtETagKey]) != fence.Token() { + t.Errorf("held fence token %q is not the stored %v", fence.Token(), f.entry(path)) } } @@ -264,8 +271,8 @@ func TestTakePresentFenceRequiresTheEntryAsRead(t *testing.T) { if len(clauses) != 1 || clauses[0].Kind != filer_pb.WriteCondition_IF_ENTRY_EQUAL || !proto.Equal(clauses[0].ExpectedEntry, previous) { t.Errorf("condition %v, want IF_ENTRY_EQUAL on %v", clauses, previous) } - if stored := f.entry(path); string(stored.Extended[mq.ExtendedAttrFenceEpoch]) != "3" || string(stored.Extended[s3_constants.ExtETagKey]) != fence.Token { - t.Errorf("stored fence %v, held token %q", stored, fence.Token) + if stored := f.entry(path); string(stored.Extended[mq.ExtendedAttrFenceEpoch]) != "3" || string(stored.Extended[s3_constants.ExtETagKey]) != fence.Token() { + t.Errorf("stored fence %v, held token %q", stored, fence.Token()) } // the same epoch can be taken again, as a restarted leader does, requiring the token as read @@ -273,10 +280,10 @@ func TestTakePresentFenceRequiresTheEntryAsRead(t *testing.T) { if err != nil { t.Fatal(err) } - if clauses := f.transactions()[1].Condition.GetClauses(); len(clauses) != 1 || clauses[0].Kind != filer_pb.WriteCondition_IF_ETAG_MATCH || !slices.Equal(clauses[0].Etags, []string{fence.Token}) { - t.Errorf("retake condition %v, want the token %q", clauses, fence.Token) + if clauses := f.transactions()[1].Condition.GetClauses(); len(clauses) != 1 || clauses[0].Kind != filer_pb.WriteCondition_IF_ETAG_MATCH || !slices.Equal(clauses[0].Etags, []string{fence.Token()}) { + t.Errorf("retake condition %v, want the token %q", clauses, fence.Token()) } - if again.Token == fence.Token { + if again.Token() == fence.Token() { t.Error("a retaken fence kept its token") } } @@ -329,7 +336,7 @@ func TestTakeFenceGivesUpOnAStalledFiler(t *testing.T) { done := make(chan error, 1) go func() { - _, err := b.newLeaderPartition(fenceTestTopic, fenceTestPartition, 1) + _, err := b.newLeaderPartition(fenceTestTopic, fenceTestPartition, &mq_pb.BrokerPartitionAssignment{Partition: fenceTestPartition.ToPbPartition(), Epoch: 1}) done <- err }() select { @@ -358,6 +365,8 @@ func TestReassignedLeaderReplacesItsFencedPartition(t *testing.T) { } assign(1) old := b.localTopicManager.GetLocalPartition(fenceTestTopic, fenceTestPartition) + // another broker led epoch 2 and sealed it + f.put(topic.PartitionFencePath(fenceTestTopic, fenceTestPartition), fenceAt("127.0.0.1:18888", "2", 1, true)) old.Fence.MarkLost() assign(3) @@ -376,7 +385,7 @@ func TestReassignedLeaderReplacesItsFencedPartition(t *testing.T) { func TestReassignmentReloadsAnOlderEpoch(t *testing.T) { f, b := newFencingFiler(t) old, _ := newFencedPartition(t, b) - if err := old.Publish(&mq_pb.DataMessage{Key: []byte("k"), Value: []byte("v"), TsNs: time.Now().UnixNano()}); err != nil { + if _, err := old.PublishWithOffset(&mq_pb.DataMessage{Key: []byte("k"), Value: []byte("v"), TsNs: time.Now().UnixNano()}); err != nil { t.Fatal(err) } assign := func(epoch int64) *topic.LocalPartition { @@ -399,8 +408,8 @@ func TestReassignmentReloadsAnOlderEpoch(t *testing.T) { t.Fatalf("serving fence %+v after an assignment at epoch 2", reloaded.Fence) } txns := f.transactions() - if len(txns) != 3 || !strings.HasPrefix(txns[1].Mutations[0].Entry.Name, "20") || txns[2].Mutations[0].Entry.Name != topic.PartitionFenceName { - t.Errorf("%d transactions, want the old copy's last window before the new fence", len(txns)) + if len(txns) != 4 || !strings.HasPrefix(txns[1].Mutations[0].Entry.Name, "20") || !fenceSealed(txns[2].Mutations[0].Entry) || txns[3].Mutations[0].Entry.Name != topic.PartitionFenceName { + t.Errorf("%d transactions, want the old copy's last window and seal before the new fence", len(txns)) } } @@ -425,7 +434,7 @@ func TestLookupReloadsAnOlderEpoch(t *testing.T) { func TestConcurrentReloadsWaitForTheLastFlush(t *testing.T) { f, b := newFencingFiler(t) old, _ := newFencedPartition(t, b) - if err := old.Publish(&mq_pb.DataMessage{Key: []byte("k"), Value: []byte("v"), TsNs: time.Now().UnixNano()}); err != nil { + if _, err := old.PublishWithOffset(&mq_pb.DataMessage{Key: []byte("k"), Value: []byte("v"), TsNs: time.Now().UnixNano()}); err != nil { t.Fatal(err) } f.uploadGate = make(chan struct{}) @@ -465,8 +474,9 @@ func TestConcurrentReloadsWaitForTheLastFlush(t *testing.T) { for _, txn := range f.transactions() { names = append(names, txn.Mutations[0].Entry.Name) } - if len(names) != 3 || names[0] != topic.PartitionFenceName || !strings.HasPrefix(names[1], "20") || names[2] != topic.PartitionFenceName { - t.Errorf("transactions %v, want the old copy's last window before one new fence", names) + txns := f.transactions() + if len(names) != 4 || names[0] != topic.PartitionFenceName || !strings.HasPrefix(names[1], "20") || !fenceSealed(txns[2].Mutations[0].Entry) || names[3] != topic.PartitionFenceName { + t.Errorf("transactions %v, want the old copy's last window and one seal before one new fence", names) } for _, txn := range f.transactions() { if f.outcome[txn.RequestId].GetErrorCode() == filer_pb.FilerError_PRECONDITION_FAILED { @@ -474,3 +484,212 @@ func TestConcurrentReloadsWaitForTheLastFlush(t *testing.T) { } } } + +func fenceAt(writer string, epoch string, mtime int64, sealed bool) *filer_pb.Entry { + e := &filer_pb.Entry{ + Name: topic.PartitionFenceName, + Attributes: &filer_pb.FuseAttributes{Mtime: mtime}, + Extended: map[string][]byte{ + mq.ExtendedAttrFenceWriter: []byte(writer), + mq.ExtendedAttrFenceEpoch: []byte(epoch), + s3_constants.ExtETagKey: []byte(writer + "/" + epoch), + }, + } + if sealed { + e.Extended[mq.ExtendedAttrFenceSealed] = []byte("true") + } + return e +} + +// A new leader leaves an unsealed fence of an earlier generation to its holder for +// a while, since the holder may still be persisting what it holds. +func TestTakeFenceWaitsForAnEarlierGenerationToSeal(t *testing.T) { + f, b := newFencingFiler(t) + path := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + f.put(path, fenceAt("127.0.0.1:18888", "2", time.Now().Unix(), false)) + if _, err := b.takePartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 3); !errors.Is(err, errFenceLost) { + t.Fatalf("took a fence its holder just renewed: %v", err) + } + f.put(path, fenceAt("127.0.0.1:18888", "2", time.Now().Unix(), true)) + if _, err := b.takePartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 3); err != nil { + t.Fatalf("could not take a sealed fence: %v", err) + } +} + +func TestTakeFenceRefusesItsGenerationHeldElsewhere(t *testing.T) { + f, b := newFencingFiler(t) + path := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + f.put(path, fenceAt("127.0.0.1:18888", "3", 1, false)) + if _, err := b.takePartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 3); !errors.Is(err, errFenceLost) { + t.Fatalf("took back a generation its follower took over: %v", err) + } + f.put(path, fenceAt("127.0.0.1:17777", "3", 1, true)) + if _, err := b.takePartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 3); !errors.Is(err, errFenceLost) { + t.Fatalf("reopened a sealed generation: %v", err) + } +} + +func TestFollowerTakesOverItsLeadersFence(t *testing.T) { + f, b := newFencingFiler(t) + path := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + leader := "127.0.0.1:18888" + + f.put(path, fenceAt(leader, "3", 1, true)) + if _, err := b.takeOverPartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 3, leader); !errors.Is(err, errFenceLost) { + t.Fatalf("took over a fence the leader sealed: %v", err) + } + f.put(path, fenceAt("127.0.0.1:19999", "3", 1, false)) + if _, err := b.takeOverPartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 3, leader); !errors.Is(err, errFenceLost) { + t.Fatalf("took over a fence another broker holds: %v", err) + } + f.put(path, fenceAt(leader, "3", 1, false)) + fence, err := b.takeOverPartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 3, leader) + if err != nil { + t.Fatal(err) + } + stored := f.entry(path) + if string(stored.Extended[mq.ExtendedAttrFenceWriter]) != "127.0.0.1:17777" || string(stored.Extended[s3_constants.ExtETagKey]) != fence.Token() { + t.Fatalf("stored %v, held token %q", stored, fence.Token()) + } +} + +// A seal replaces the token, so a follower that read the fence before the seal +// cannot take it over after. +func TestSealingReplacesTheToken(t *testing.T) { + f, b := newFencingFiler(t) + path := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + fence, err := b.takePartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 1) + if err != nil { + t.Fatal(err) + } + before := fence.Token() + if err := b.renewPartitionFence(context.Background(), fence, false); err != nil { + t.Fatal(err) + } + if fence.Token() != before { + t.Fatal("a renewal replaced the token, failing flushes already under way") + } + if err := b.renewPartitionFence(context.Background(), fence, true); err != nil { + t.Fatal(err) + } + stored := f.entry(path) + if !fenceSealed(stored) || fence.Token() == before || string(stored.Extended[s3_constants.ExtETagKey]) != fence.Token() { + t.Fatalf("stored %v, held token %q", stored, fence.Token()) + } + if err := b.fencedTransaction(context.Background(), path, fenceTokenCondition(before), "late-takeover", &filer_pb.ObjectMutation{Type: filer_pb.ObjectMutation_PUT, Directory: topic.PartitionDir(fenceTestTopic, fenceTestPartition), Entry: fenceAt("127.0.0.1:18888", "1", 1, false)}); !errors.Is(err, errFenceLost) { + t.Fatalf("a write holding the pre-seal token went through: %v", err) + } + + // a holder whose fence moved on is told so, and marks it lost + f.put(path, fenceAt("127.0.0.1:18888", "2", 1, false)) + if err := b.renewPartitionFence(context.Background(), fence, true); !errors.Is(err, errFenceLost) || !fence.IsLost() { + t.Fatalf("renewed a fence another broker holds: %v", err) + } +} + +// A holder persisting what it holds keeps its fence fresh, so a new leader keeps +// waiting however long that takes, and takes the fence once the holder stops. +func TestPersistingHolderKeepsItsFenceRenewed(t *testing.T) { + f, b := newFencingFiler(t) + defer func(interval time.Duration) { fenceRenewInterval = interval }(fenceRenewInterval) + fenceRenewInterval = 20 * time.Millisecond + path := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + fence, err := b.takePartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 1) + if err != nil { + t.Fatal(err) + } + // taken long ago, as a leader's fence is when its generation ends + stale := proto.Clone(f.entry(path)).(*filer_pb.Entry) + stale.Attributes.Mtime = time.Now().Add(-time.Hour).Unix() + f.put(path, stale) + + stop := b.keepFenceRenewed(fence) + for deadline := time.Now().Add(5 * time.Second); f.entry(path).Attributes.Mtime < time.Now().Add(-fenceSealWait).Unix(); time.Sleep(5 * time.Millisecond) { + if time.Now().After(deadline) { + t.Fatal("fence not renewed") + } + } + _, other := newFencingFiler(t) + other.currentFiler, other.option = b.currentFiler, &MessageQueueBrokerOption{Ip: "127.0.0.1", Port: 18888} + if _, err := other.takePartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 2); !errors.Is(err, errFenceLost) { + t.Fatalf("a new leader took a fence its holder is renewing: %v", err) + } + stop() + stop() + if string(f.entry(path).Extended[s3_constants.ExtETagKey]) != fence.Token() || fence.IsLost() { + t.Fatal("renewals changed the token") + } +} + +// A renewal that lands only after its retries carries the time it landed. +func TestLateRenewalIsStampedWhenItLands(t *testing.T) { + f, b := newFencingFiler(t) + path := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + fence, err := b.takePartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 1) + if err != nil { + t.Fatal(err) + } + f.mu.Lock() + f.failMutations = 3 + f.mu.Unlock() + start := time.Now().Unix() + if err := b.renewPartitionFence(context.Background(), fence, false); err != nil { + t.Fatal(err) + } + landed := f.entry(path).Attributes.Mtime + if elapsed := time.Now().Unix() - start; elapsed < 2 { + t.Fatalf("retries took %ds, too short to tell the stamps apart", elapsed) + } + if landed <= start { + t.Fatalf("renewal stamped %d, before it landed (started %d)", landed, start) + } +} + +// A holder that renews between a new leader's staleness check and its write keeps +// the fence: the renewal changes only the mtime, so the token alone would not tell. +func TestTakeFenceLosesToARenewalAfterItsCheck(t *testing.T) { + f, b := newFencingFiler(t) + path := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + f.put(path, fenceAt("127.0.0.1:18888", "2", time.Now().Add(-time.Hour).Unix(), false)) + f.beforeApply = func() { + renewed := proto.Clone(f.entries[path]).(*filer_pb.Entry) + renewed.Attributes.Mtime = time.Now().Unix() + f.entries[path] = renewed + } + if _, err := b.takePartitionFence(context.Background(), fenceTestTopic, fenceTestPartition, 3); !errors.Is(err, errFenceLost) { + t.Fatalf("took a fence its holder renewed after the check: %v", err) + } + if writer := string(f.entry(path).Extended[mq.ExtendedAttrFenceWriter]); writer != "127.0.0.1:18888" { + t.Fatalf("fence moved to %s", writer) + } +} + +// A leader whose follower cannot be reached seals and reports under the access +// lock, so a filer that keeps failing must not hold the load forever. +func TestFailedReplicaStartDoesNotWaitOnAFailingFiler(t *testing.T) { + f, b := newFencingFiler(t) + defer func(timeout time.Duration) { fenceTakeTimeout = timeout }(fenceTakeTimeout) + fenceTakeTimeout = 500 * time.Millisecond + took := false + f.beforeApply = func() { + if took { + f.failMutations = 1 << 30 + } + took = true + } + done := make(chan error, 1) + go func() { + _, err := b.newLeaderPartition(fenceTestTopic, fenceTestPartition, &mq_pb.BrokerPartitionAssignment{ + Partition: fenceTestPartition.ToPbPartition(), Epoch: 1, FollowerBroker: "127.0.0.1:1", + }) + done <- err + }() + select { + case err := <-done: + if !errors.Is(err, errGenerationEnded) { + t.Fatalf("load with an unreachable follower returned %v", err) + } + case <-time.After(15 * time.Second): + t.Fatal("seal after a failed replica start never gave up") + } +} diff --git a/weed/mq/broker/broker_replication_test.go b/weed/mq/broker/broker_replication_test.go new file mode 100644 index 0000000000..5866866aa5 --- /dev/null +++ b/weed/mq/broker/broker_replication_test.go @@ -0,0 +1,478 @@ +package broker + +import ( + "context" + "encoding/binary" + "errors" + "fmt" + "io" + "net" + "sort" + "testing" + "time" + + "github.com/seaweedfs/seaweedfs/weed/filer_client" + "github.com/seaweedfs/seaweedfs/weed/mq" + "github.com/seaweedfs/seaweedfs/weed/mq/topic" + "github.com/seaweedfs/seaweedfs/weed/pb" + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" + "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" + "github.com/seaweedfs/seaweedfs/weed/util" + "github.com/seaweedfs/seaweedfs/weed/util/log_buffer" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +func startFollower(t *testing.T, srv mq_pb.SeaweedMessagingServer) (string, *grpc.Server) { + listener, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatal(err) + } + server := grpc.NewServer() + mq_pb.RegisterSeaweedMessagingServer(server, srv) + go server.Serve(listener) + t.Cleanup(server.Stop) + return listener.Addr().String(), server +} + +func startReplica(t *testing.T, follower string) *topic.Replicator { + replica, err := topic.StartReplicator(follower, grpc.WithTransportCredentials(insecure.NewCredentials()), &mq_pb.PublishFollowMeRequest_InitMessage{ + Topic: &schema_pb.Topic{Namespace: "test", Name: "t"}, + Partition: &schema_pb.Partition{RingSize: 2520, RangeStop: 2520, UnixTimeNs: 1}, + Epoch: 1, + Leader: "127.0.0.1:17777", + }) + if err != nil { + t.Fatal(err) + } + return replica +} + +func TestReplicaAcksWhatTheFollowerHolds(t *testing.T) { + follower, _ := startFollower(t, &MessageQueueBroker{}) + replica := startReplica(t, follower) + + for offset := int64(0); offset < 100; offset++ { + if err := replica.Send(&filer_pb.LogEntry{TsNs: time.Now().UnixNano(), Key: []byte("k"), Offset: offset}); err != nil { + t.Fatal(err) + } + } + if err := replica.WaitAcked(99); err != nil { + t.Fatal(err) + } + replica.Flushed(99) + + replica.Close() + if err := replica.Err(); !errors.Is(err, topic.ErrReplicaClosed) { + t.Fatalf("closed replica reports %v", err) + } +} + +func TestReplicaBreaksWhenTheFollowerGoes(t *testing.T) { + follower, server := startFollower(t, &MessageQueueBroker{}) + replica := startReplica(t, follower) + if err := replica.Send(&filer_pb.LogEntry{TsNs: time.Now().UnixNano(), Offset: 0}); err != nil { + t.Fatal(err) + } + if err := replica.WaitAcked(0); err != nil { + t.Fatal(err) + } + + server.Stop() + + select { + case <-replica.Broken(): + case <-time.After(10 * time.Second): + t.Fatal("pair not broken after the follower stopped") + } + if err := replica.WaitAcked(1); err == nil { + t.Fatal("an offset the follower never held was acked") + } +} + +// silentFollower takes the stream and never answers, as a hung broker would. +type silentFollower struct { + mq_pb.UnimplementedSeaweedMessagingServer +} + +func (silentFollower) PublishFollowMe(stream mq_pb.SeaweedMessaging_PublishFollowMeServer) error { + for { + if _, err := stream.Recv(); err != nil { + return err + } + } +} + +func TestReplicaBreaksWhenTheFollowerFallsSilent(t *testing.T) { + follower, _ := startFollower(t, silentFollower{}) + replica := startReplica(t, follower) + select { + case <-replica.Broken(): + case <-time.After(15 * time.Second): + t.Fatal("pair not broken after the follower fell silent") + } +} + +// A leader that loses its follower stores what it holds under its fence and seals it. +// stuckFollower takes the stream and stops reading, so the leader's sends block. +type stuckFollower struct { + mq_pb.UnimplementedSeaweedMessagingServer +} + +func (stuckFollower) PublishFollowMe(stream mq_pb.SeaweedMessaging_PublishFollowMeServer) error { + <-stream.Context().Done() + return nil +} + +func TestReplicaBreaksWhenASendBlocks(t *testing.T) { + follower, _ := startFollower(t, stuckFollower{}) + replica := startReplica(t, follower) + value := make([]byte, 64*1024) + go func() { + for offset := int64(0); ; offset++ { + if replica.Send(&filer_pb.LogEntry{Offset: offset, Data: value}) != nil { + return + } + } + }() + select { + case <-replica.Broken(): + case <-time.After(15 * time.Second): + t.Fatal("pair not broken while sends to the follower were blocked") + } +} + +func TestLeaderStoresAndSealsWhenItLosesItsFollower(t *testing.T) { + f, leader := newFencingFiler(t) + leader.localTopicManager = topic.NewLocalTopicManager() + leader.fca = &filer_client.FilerClientAccessor{ + GetGrpcDialOption: leader.GetGrpcDialOption, + GetFilers: func() []pb.ServerAddress { return []pb.ServerAddress{leader.GetFiler()} }, + } + followerAddr, followerServer := startFollower(t, &MessageQueueBroker{}) + + lp, err := leader.newLeaderPartition(fenceTestTopic, fenceTestPartition, &mq_pb.BrokerPartitionAssignment{ + Partition: fenceTestPartition.ToPbPartition(), + LeaderBroker: "127.0.0.1:17777", + FollowerBroker: followerAddr, + Epoch: 1, + }) + if err != nil { + t.Fatal(err) + } + leader.localTopicManager.AddLocalPartition(fenceTestTopic, lp) + go leader.watchReplica(fenceTestTopic, fenceTestPartition, lp, 1) + for i := 0; i < 10; i++ { + offset, err := lp.PublishWithOffset(&mq_pb.DataMessage{Key: []byte("k"), Value: []byte("v"), TsNs: time.Now().UnixNano()}) + if err != nil { + t.Fatal(err) + } + if err := lp.Replica.WaitAcked(offset); err != nil { + t.Fatal(err) + } + } + + followerServer.Stop() + + fencePath := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + deadline := time.Now().Add(20 * time.Second) + for !fenceSealed(f.entry(fencePath)) { + if time.Now().After(deadline) { + t.Fatal("fence not sealed after the follower was lost") + } + time.Sleep(50 * time.Millisecond) + } + if _, err := lp.PublishWithOffset(&mq_pb.DataMessage{Key: []byte("k"), Value: []byte("late"), TsNs: time.Now().UnixNano()}); err == nil { + t.Fatal("a broken pair accepted a publish") + } + var stored mq.OffsetRange + dir := topic.PartitionDir(fenceTestTopic, fenceTestPartition) + f.mu.Lock() + for path, entry := range f.entries { + if d, name := util.FullPath(path).DirAndName(); d == dir && name != topic.PartitionFenceName { + stored.Add(entry.Extended) + } + } + f.mu.Unlock() + if earliest, hwm := stored.Bounds(); earliest != 0 || hwm != 10 { + t.Fatalf("stored offsets %d..%d, want 0..9", earliest, hwm-1) + } +} + +// A follower whose leader vanishes takes the fence and stores what the leader had +// not, exactly once. +func TestFollowerTakesOverALostLeader(t *testing.T) { + f, follower := newFencingFiler(t) + follower.fca = &filer_client.FilerClientAccessor{ + GetGrpcDialOption: follower.GetGrpcDialOption, + GetFilers: func() []pb.ServerAddress { return []pb.ServerAddress{follower.GetFiler()} }, + } + followerAddr, _ := startFollower(t, follower) + leaderAddr := "127.0.0.1:18888" + fencePath := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + dir := topic.PartitionDir(fenceTestTopic, fenceTestPartition) + f.put(fencePath, fenceAt(leaderAddr, "1", time.Now().Unix(), false)) + // the leader had stored offsets 0..4 before it went + f.put(dir+"/"+topic.LogFileName(time.Now(), 0), &filer_pb.Entry{Name: topic.LogFileName(time.Now(), 0), Attributes: &filer_pb.FuseAttributes{}, Extended: rangeExtended(0, 4)}) + + conn, err := grpc.NewClient(followerAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + t.Fatal(err) + } + defer conn.Close() + ctx, vanish := context.WithCancel(context.Background()) + stream, err := mq_pb.NewSeaweedMessagingClient(conn).PublishFollowMe(ctx) + if err != nil { + t.Fatal(err) + } + if err := stream.Send(&mq_pb.PublishFollowMeRequest{Message: &mq_pb.PublishFollowMeRequest_Init{Init: &mq_pb.PublishFollowMeRequest_InitMessage{ + Topic: fenceTestTopic.ToPbTopic(), Partition: fenceTestPartition.ToPbPartition(), Epoch: 1, Leader: leaderAddr, + }}}); err != nil { + t.Fatal(err) + } + for offset := int64(0); offset < 10; offset++ { + if err := stream.Send(&mq_pb.PublishFollowMeRequest{Message: &mq_pb.PublishFollowMeRequest_Entry{Entry: &filer_pb.LogEntry{TsNs: time.Now().UnixNano(), Key: []byte("k"), Data: []byte("v"), Offset: offset}}}); err != nil { + t.Fatal(err) + } + if ack, err := stream.Recv(); err != nil || ack.AckOffset != offset { + t.Fatalf("ack %v, %v; want offset %d", ack, err, offset) + } + } + vanish() + + deadline := time.Now().Add(20 * time.Second) + for !fenceSealed(f.entry(fencePath)) { + if time.Now().After(deadline) { + t.Fatal("follower did not take over and seal") + } + time.Sleep(50 * time.Millisecond) + } + if writer := string(f.entry(fencePath).Extended[mq.ExtendedAttrFenceWriter]); writer != follower.option.BrokerAddress().String() { + t.Fatalf("fence held by %s", writer) + } + if stored, want := storedRanges(f, dir), []string{"0-4", "5-9"}; fmt.Sprint(stored) != fmt.Sprint(want) { + t.Fatalf("stored ranges %v, want %v", stored, want) + } +} + +// storedRanges lists the offset ranges of the log files in dir. +func storedRanges(f *fencingFiler, dir string) (stored []string) { + f.mu.Lock() + defer f.mu.Unlock() + for path, entry := range f.entries { + if d, name := util.FullPath(path).DirAndName(); d == dir && name != topic.PartitionFenceName { + var r mq.OffsetRange + r.Add(entry.Extended) + earliest, hwm := r.Bounds() + stored = append(stored, fmt.Sprintf("%d-%d", earliest, hwm-1)) + } + } + sort.Strings(stored) + return stored +} + +// ackFailingStream delivers the leader's messages but fails the follower's ack +// at failAt, as a connection that broke while the follower answered. +type ackFailingStream struct { + grpc.ServerStream + ctx context.Context + reqs []*mq_pb.PublishFollowMeRequest + acks int + failAt int +} + +func (s *ackFailingStream) Context() context.Context { return s.ctx } + +func (s *ackFailingStream) Recv() (*mq_pb.PublishFollowMeRequest, error) { + if len(s.reqs) == 0 { + <-s.ctx.Done() + return nil, s.ctx.Err() + } + req := s.reqs[0] + s.reqs = s.reqs[1:] + return req, nil +} + +func (s *ackFailingStream) Send(*mq_pb.PublishFollowMeResponse) error { + if s.acks++; s.acks == s.failAt { + return io.ErrClosedPipe + } + return nil +} + +func TestFollowerTakesOverWhenItCannotAck(t *testing.T) { + f, follower := newFencingFiler(t) + leaderAddr := "127.0.0.1:18888" + fencePath := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + f.put(fencePath, fenceAt(leaderAddr, "1", time.Now().Unix(), false)) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + stream := &ackFailingStream{ctx: ctx, failAt: 5} + stream.reqs = append(stream.reqs, &mq_pb.PublishFollowMeRequest{Message: &mq_pb.PublishFollowMeRequest_Init{Init: &mq_pb.PublishFollowMeRequest_InitMessage{ + Topic: fenceTestTopic.ToPbTopic(), Partition: fenceTestPartition.ToPbPartition(), Epoch: 1, Leader: leaderAddr, + }}}) + for offset := int64(0); offset < 5; offset++ { + stream.reqs = append(stream.reqs, &mq_pb.PublishFollowMeRequest{Message: &mq_pb.PublishFollowMeRequest_Entry{Entry: &filer_pb.LogEntry{TsNs: time.Now().UnixNano(), Key: []byte("k"), Data: []byte("v"), Offset: offset}}}) + } + done := make(chan error, 1) + go func() { done <- follower.PublishFollowMe(stream) }() + select { + case <-done: + case <-time.After(20 * time.Second): + t.Fatal("follower kept waiting after its ack failed") + } + if !fenceSealed(f.entry(fencePath)) { + t.Fatal("follower did not take over and seal") + } + if stored, want := storedRanges(f, topic.PartitionDir(fenceTestTopic, fenceTestPartition)), []string{"0-4"}; fmt.Sprint(stored) != fmt.Sprint(want) { + t.Fatalf("stored ranges %v, want %v", stored, want) + } +} + +func rangeExtended(min, max int64) map[string][]byte { + return map[string][]byte{ + mq.ExtendedAttrOffsetMin: binary.BigEndian.AppendUint64(nil, uint64(min)), + mq.ExtendedAttrOffsetMax: binary.BigEndian.AppendUint64(nil, uint64(max)), + } +} + +// A follower whose filer briefly fails keeps the only copy of what the leader had +// not stored and retries, rather than give up the takeover. +func TestFollowerTakeoverRetriesAFilerError(t *testing.T) { + f, follower := newFencingFiler(t) + leaderAddr := "127.0.0.1:18888" + fencePath := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + dir := topic.PartitionDir(fenceTestTopic, fenceTestPartition) + f.put(fencePath, fenceAt(leaderAddr, "1", time.Now().Unix(), false)) + f.put(dir+"/"+topic.LogFileName(time.Now(), 0), &filer_pb.Entry{Name: topic.LogFileName(time.Now(), 0), Attributes: &filer_pb.FuseAttributes{}, Extended: rangeExtended(0, 4)}) + f.mu.Lock() + f.failLists = 2 + f.mu.Unlock() + + var held []*filer_pb.LogEntry + for offset := int64(0); offset < 10; offset++ { + held = append(held, &filer_pb.LogEntry{TsNs: time.Now().UnixNano(), Key: []byte("k"), Data: []byte("v"), Offset: offset}) + } + follower.takeOverPartition(fenceTestTopic, fenceTestPartition, &mq_pb.PublishFollowMeRequest_InitMessage{Epoch: 1, Leader: leaderAddr}, held) + + if !fenceSealed(f.entry(fencePath)) { + t.Fatal("follower gave up the takeover") + } + if stored, want := storedRanges(f, dir), []string{"0-4", "5-9"}; fmt.Sprint(stored) != fmt.Sprint(want) { + t.Fatalf("stored ranges %v, want %v", stored, want) + } +} + +// endingFollower acks every entry and reports how its stream ended. +type endingFollower struct { + mq_pb.UnimplementedSeaweedMessagingServer + ended chan string +} + +func (f endingFollower) PublishFollowMe(stream mq_pb.SeaweedMessaging_PublishFollowMeServer) error { + for { + req, err := stream.Recv() + if err != nil { + f.ended <- "broken" + return nil + } + if req.GetClose() != nil { + f.ended <- "closed" + return nil + } + if entry := req.GetEntry(); entry != nil { + if err := stream.Send(&mq_pb.PublishFollowMeResponse{AckOffset: entry.Offset}); err != nil { + f.ended <- "broken" + return nil + } + } + } +} + +// A leader whose last flush was dropped leaves the follower to store its copy +// instead of telling it everything is stored. +func TestRetiredLeaderClosesItsFollowerOnlyWhenAllIsStored(t *testing.T) { + for _, tc := range []struct { + dropFlush bool + want string + }{{false, "closed"}, {true, "broken"}} { + follower := endingFollower{ended: make(chan string, 1)} + addr, _ := startFollower(t, follower) + flush := func(logBuffer *log_buffer.LogBuffer, _, _ time.Time, buf []byte, _, _ int64) { + if tc.dropFlush { + logBuffer.NoteFlushDropped(len(buf)) + } + } + manager := topic.NewLocalTopicManager() + lp := topic.NewLocalPartition(fenceTestPartition, 3600, flush, nil) + lp.Replica = startReplica(t, addr) + manager.AddLocalPartition(fenceTestTopic, lp) + if _, err := lp.PublishWithOffset(&mq_pb.DataMessage{Key: []byte("k"), Value: []byte("v"), TsNs: time.Now().UnixNano()}); err != nil { + t.Fatal(err) + } + manager.RemoveLocalPartition(fenceTestTopic, lp) + if err := manager.WaitRetired(context.Background(), fenceTestTopic, fenceTestPartition); err != nil { + t.Fatal(err) + } + select { + case got := <-follower.ended: + if got != tc.want { + t.Errorf("dropped flush %v: follow stream %s, want %s", tc.dropFlush, got, tc.want) + } + case <-time.After(10 * time.Second): + t.Fatalf("dropped flush %v: follow stream never ended", tc.dropFlush) + } + } +} + +// refusingFollower takes the init and then drops the stream. +type refusingFollower struct { + mq_pb.UnimplementedSeaweedMessagingServer +} + +func (refusingFollower) PublishFollowMe(stream mq_pb.SeaweedMessaging_PublishFollowMeServer) error { + if _, err := stream.Recv(); err != nil { + return err + } + return io.ErrUnexpectedEOF +} + +// A pair that breaks before its partition is registered ends the generation +// only once it is, so the generation never ends under a partition still to be served. +func TestPairBrokenBeforeRegistrationEndsOnceRegistered(t *testing.T) { + f, leader := newFencingFiler(t) + leader.localTopicManager = topic.NewLocalTopicManager() + followerAddr, _ := startFollower(t, refusingFollower{}) + lp, err := leader.newLeaderPartition(fenceTestTopic, fenceTestPartition, &mq_pb.BrokerPartitionAssignment{ + Partition: fenceTestPartition.ToPbPartition(), + LeaderBroker: "127.0.0.1:17777", + FollowerBroker: followerAddr, + Epoch: 1, + }) + if err != nil { + t.Fatal(err) + } + select { + case <-lp.Replica.Broken(): + case <-time.After(10 * time.Second): + t.Fatal("pair did not break") + } + fencePath := topic.PartitionFencePath(fenceTestTopic, fenceTestPartition) + time.Sleep(200 * time.Millisecond) + if fenceSealed(f.entry(fencePath)) { + t.Fatal("generation ended before its partition was registered") + } + + leader.localTopicManager.AddLocalPartition(fenceTestTopic, lp) + go leader.watchReplica(fenceTestTopic, fenceTestPartition, lp, 1) + for deadline := time.Now().Add(10 * time.Second); !fenceSealed(f.entry(fencePath)); time.Sleep(20 * time.Millisecond) { + if time.Now().After(deadline) { + t.Fatal("generation not ended once registered") + } + } + if leader.localTopicManager.GetLocalPartition(fenceTestTopic, fenceTestPartition) == lp { + t.Fatal("ended generation still registered") + } +} diff --git a/weed/mq/broker/broker_server.go b/weed/mq/broker/broker_server.go index 7f72599fad..d337a0867f 100644 --- a/weed/mq/broker/broker_server.go +++ b/weed/mq/broker/broker_server.go @@ -70,7 +70,9 @@ type MessageQueueBroker struct { SubCoordinator *sub_coordinator.SubCoordinator // Removed gatewayRegistry - no longer needed accessLock sync.Mutex - fca *filer_client.FilerClientAccessor + // orders read-modify-writes of topic.conf, all of which run on the balancer + topicConfLock sync.Mutex + fca *filer_client.FilerClientAccessor // Unified topic cache for both existence and configuration // Caches topic config (positive: conf != nil) and non-existence (negative: conf == nil) // Eliminates 60% CPU overhead from repeated filer reads and JSON unmarshaling diff --git a/weed/mq/broker/broker_topic_conf_read_write.go b/weed/mq/broker/broker_topic_conf_read_write.go index b118052032..84d437b142 100644 --- a/weed/mq/broker/broker_topic_conf_read_write.go +++ b/weed/mq/broker/broker_topic_conf_read_write.go @@ -71,6 +71,8 @@ func (b *MessageQueueBroker) getTopicConfFromCache(t topic.Topic) (*mq_pb.Config // Cache miss or expired - read from filer glog.V(4).Infof("Topic cache MISS for %s, reading from filer", topicKey) + b.topicConfLock.Lock() + defer b.topicConfLock.Unlock() conf, readConfErr := b.fca.ReadTopicConfFromFiler(t) if readConfErr != nil { @@ -183,7 +185,7 @@ func (b *MessageQueueBroker) genLocalPartitionFromFiler(t topic.Topic, partition if pb.ServerAddress(assignment.LeaderBroker).Equals(self) && partition.LogicalEquals(assignmentPartition) { partition = assignmentPartition glog.V(4).Infof("Creating local partition for %s %s", t, partition) - if localPartition, err = b.newLeaderPartition(t, partition, assignment.Epoch); err != nil { + if localPartition, err = b.newLeaderPartition(t, partition, assignment); err != nil { return nil, false, err } @@ -191,6 +193,7 @@ func (b *MessageQueueBroker) genLocalPartitionFromFiler(t topic.Topic, partition localPartition.Shutdown() return nil, false, fmt.Errorf("broker is stopping") } + go b.watchReplica(t, partition, localPartition, assignment.Epoch) isGenerated = true glog.V(4).Infof("Successfully added local partition %s %s to localTopicManager", t, partition) break diff --git a/weed/mq/broker/broker_topic_partition_read_write.go b/weed/mq/broker/broker_topic_partition_read_write.go index de4005fb74..90b59671b1 100644 --- a/weed/mq/broker/broker_topic_partition_read_write.go +++ b/weed/mq/broker/broker_topic_partition_read_write.go @@ -55,7 +55,7 @@ func (b *MessageQueueBroker) genLogFlushFunc(t topic.Topic, p topic.Partition, f b.accessLock.Lock() defer b.accessLock.Unlock() if localPartition := b.localTopicManager.GetLocalPartition(t, p); localPartition != nil { - localPartition.NotifyLogFlushed(logBuffer.GetLastFlushTsNs()) + localPartition.NotifyLogFlushed(maxOffset) } glog.V(0).Infof("flushing at %d to %s size %d from buffer %s (offsets %d-%d)", logBuffer.GetLastFlushTsNs(), targetFile, len(buf), logBuffer.GetName(), minOffset, maxOffset) diff --git a/weed/mq/broker/broker_write.go b/weed/mq/broker/broker_write.go index f9f6fac925..eba5c01296 100644 --- a/weed/mq/broker/broker_write.go +++ b/weed/mq/broker/broker_write.go @@ -74,7 +74,7 @@ func (b *MessageQueueBroker) writeLogFile(ctx context.Context, fence *topic.Part } } - condition := fenceTokenCondition(fence.Token) + condition := fenceTokenCondition(fence.Token()) mutation := &filer_pb.ObjectMutation{Type: filer_pb.ObjectMutation_PUT, Directory: dir, Entry: entry} requestId := uuid.NewString() err := retryLogWrite(ctx, targetFile, func() error { diff --git a/weed/mq/broker/broker_write_test.go b/weed/mq/broker/broker_write_test.go index 012ea2ae2e..0e86223b93 100644 --- a/weed/mq/broker/broker_write_test.go +++ b/weed/mq/broker/broker_write_test.go @@ -72,7 +72,7 @@ func TestStoppingBrokerAbandonsAFailingFlush(t *testing.T) { currentFiler: pb.NewServerAddressWithGrpcPort(listener.Addr().String(), listener.Addr().(*net.TCPAddr).Port), flushCtx: flushCtx, } - fence := &topic.PartitionFence{Path: topic.PartitionFencePath(fenceTestTopic, fenceTestPartition), Token: "token"} + fence := topic.NewPartitionFence(topic.PartitionFencePath(fenceTestTopic, fenceTestPartition), 0, "token") flush := b.genLogFlushFunc(fenceTestTopic, fenceTestPartition, fence) logBuffer := log_buffer.NewLogBuffer("test", time.Hour, flush, nil, nil) defer logBuffer.ShutdownLogBuffer() @@ -136,7 +136,7 @@ func TestFlushWritesOneFencedFilePerWindow(t *testing.T) { if txn.LockKey != fence.Path || txn.ConditionKey != fence.Path || txn.RouteKey != s3_constants.ObjectWriteRouteKeyPrefix+fence.Path { t.Errorf("transaction keys lock=%q condition=%q route=%q", txn.LockKey, txn.ConditionKey, txn.RouteKey) } - if clauses := txn.Condition.GetClauses(); len(clauses) != 1 || clauses[0].Kind != filer_pb.WriteCondition_IF_ETAG_MATCH || len(clauses[0].Etags) != 1 || clauses[0].Etags[0] != fence.Token { + if clauses := txn.Condition.GetClauses(); len(clauses) != 1 || clauses[0].Kind != filer_pb.WriteCondition_IF_ETAG_MATCH || len(clauses[0].Etags) != 1 || clauses[0].Etags[0] != fence.Token() { t.Errorf("condition %v, want the held fence's token", txn.Condition) } diff --git a/weed/mq/kafka/integration/broker_error_mapping.go b/weed/mq/kafka/integration/broker_error_mapping.go index dbeba1f064..098c2d2ca6 100644 --- a/weed/mq/kafka/integration/broker_error_mapping.go +++ b/weed/mq/kafka/integration/broker_error_mapping.go @@ -72,6 +72,8 @@ func MapBrokerErrorToKafka(brokerErrorCode int32) int16 { return kafkaErrorCodeNetworkException case 102: // BrokerErrorFollowerConnectionFailed return kafkaErrorCodeNetworkException + case 103: // BrokerErrorGenerationEnded: the partition moves to a new pair + return kafkaErrorCodeNotLeaderOrFollower default: // Unknown broker error code, default to unknown server error return kafkaErrorCodeUnknownServerError diff --git a/weed/mq/kafka/integration/broker_error_mapping_test.go b/weed/mq/kafka/integration/broker_error_mapping_test.go index 1fdef155bf..89b06aedc6 100644 --- a/weed/mq/kafka/integration/broker_error_mapping_test.go +++ b/weed/mq/kafka/integration/broker_error_mapping_test.go @@ -30,6 +30,7 @@ func TestMapBrokerErrorToKafka(t *testing.T) { {"Publisher not found", 100, kafkaErrorCodeUnknownServerError}, {"Connection failed", 101, kafkaErrorCodeNetworkException}, {"Follower connection failed", 102, kafkaErrorCodeNetworkException}, + {"Generation ended", 103, kafkaErrorCodeNotLeaderOrFollower}, {"Unknown error code", 999, kafkaErrorCodeUnknownServerError}, } diff --git a/weed/mq/pub_balancer/allocate.go b/weed/mq/pub_balancer/allocate.go index 4837b6a12a..3a945ce0ab 100644 --- a/weed/mq/pub_balancer/allocate.go +++ b/weed/mq/pub_balancer/allocate.go @@ -1,7 +1,9 @@ package pub_balancer import ( + "cmp" "math/rand/v2" + "slices" "time" cmap "github.com/orcaman/concurrent-map/v2" @@ -149,3 +151,29 @@ func EnsureAssignmentsToActiveBrokers(activeBrokers cmap.ConcurrentMap[string, * glog.V(4).Infof("EnsureAssignmentsToActiveBrokers: activeBrokers: %v, followerCount: %d, assignments: %v hasChanges: %v", activeBrokers.Count(), followerCount, assignments, hasChanges) return } + +// ReassignPartition gives a partition whose pair broke a new pair and the next epoch, +// preferring brokers outside the old pair, which may hold the broken half. +func ReassignPartition(activeBrokers cmap.ConcurrentMap[string, *BrokerStats], assignment *mq_pb.BrokerPartitionAssignment) { + candidates := make([]string, 0, activeBrokers.Count()) + for brokerStatsItem := range activeBrokers.IterBuffered() { + candidates = append(candidates, brokerStatsItem.Key) + } + pick := func(excluded ...string) string { + var pool []string + for _, c := range candidates { + if !slices.ContainsFunc(excluded, func(e string) bool { return e != "" && pb.ServerAddress(c).Equals(pb.ServerAddress(e)) }) { + pool = append(pool, c) + } + } + if picked := pickBrokersExcluded(pool, 1, "", ""); len(picked) > 0 { + return picked[0] + } + return "" + } + oldLeader, oldFollower := assignment.LeaderBroker, assignment.FollowerBroker + leader := cmp.Or(pick(oldLeader, oldFollower), pick(oldLeader), pick(), oldLeader) + follower := cmp.Or(pick(leader, oldLeader, oldFollower), pick(leader, oldLeader), pick(leader)) + assignment.LeaderBroker, assignment.FollowerBroker = leader, follower + assignment.Epoch++ +} diff --git a/weed/mq/pub_balancer/allocate_test.go b/weed/mq/pub_balancer/allocate_test.go index 7baa9a6eb4..90d682e802 100644 --- a/weed/mq/pub_balancer/allocate_test.go +++ b/weed/mq/pub_balancer/allocate_test.go @@ -277,3 +277,24 @@ func TestEnsureAssignmentsBumpsEpochOnlyWithTheLeader(t *testing.T) { assert.True(t, EnsureAssignmentsToActiveBrokers(brokerSet("localhost:1"), 1, []*mq_pb.BrokerPartitionAssignment{unassigned})) assert.Equal(t, int64(1), unassigned.Epoch) } + +func TestReassignPartitionPrefersBrokersOutsideTheOldPair(t *testing.T) { + assignment := &mq_pb.BrokerPartitionAssignment{LeaderBroker: "localhost:1", FollowerBroker: "localhost:2", Epoch: 4} + ReassignPartition(brokerSet("localhost:1", "localhost:2", "localhost:3", "localhost:4"), assignment) + assert.Equal(t, int64(5), assignment.Epoch) + assert.NotContains(t, []string{"localhost:1", "localhost:2"}, assignment.LeaderBroker) + assert.NotContains(t, []string{"localhost:1", "localhost:2", assignment.LeaderBroker}, assignment.FollowerBroker) + + // with only the survivor and one more broker, the pair is rebuilt from them + assignment = &mq_pb.BrokerPartitionAssignment{LeaderBroker: "localhost:1", FollowerBroker: "localhost:2", Epoch: 4} + ReassignPartition(brokerSet("localhost:2", "localhost:3"), assignment) + assert.Equal(t, "localhost:3", assignment.LeaderBroker) + assert.Equal(t, "localhost:2", assignment.FollowerBroker) + assert.Equal(t, int64(5), assignment.Epoch) + + // a lone survivor leads without a follower + assignment = &mq_pb.BrokerPartitionAssignment{LeaderBroker: "localhost:1", FollowerBroker: "localhost:2", Epoch: 4} + ReassignPartition(brokerSet("localhost:2"), assignment) + assert.Equal(t, "localhost:2", assignment.LeaderBroker) + assert.Equal(t, "", assignment.FollowerBroker) +} diff --git a/weed/mq/topic/local_manager.go b/weed/mq/topic/local_manager.go index 70dabe376d..db4045f843 100644 --- a/weed/mq/topic/local_manager.go +++ b/weed/mq/topic/local_manager.go @@ -151,6 +151,7 @@ func (manager *LocalTopicManager) markRetiring(t Topic, p *LocalPartition) { manager.retiring[p] = r go func() { p.LogBuffer.WaitForShutdown() + p.closeReplica() manager.retiringMu.Lock() delete(manager.retiring, p) manager.retiringMu.Unlock() diff --git a/weed/mq/topic/local_partition.go b/weed/mq/topic/local_partition.go index 8973b821b7..84f2f44705 100644 --- a/weed/mq/topic/local_partition.go +++ b/weed/mq/topic/local_partition.go @@ -1,7 +1,6 @@ package topic import ( - "context" "fmt" "strings" "sync" @@ -9,13 +8,8 @@ import ( "time" "github.com/seaweedfs/seaweedfs/weed/glog" - "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" - "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "github.com/seaweedfs/seaweedfs/weed/util/log_buffer" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) type LocalPartition struct { @@ -34,9 +28,10 @@ type LocalPartition struct { // held while this broker leads the partition; nil on a follower Fence *PartitionFence - publishFolloweMeStream mq_pb.SeaweedMessaging_PublishFollowMeClient - followerGrpcConnection *grpc.ClientConn - Follower string + // replicates to the follower while this broker leads a replicated partition + Replica *Replicator + Follower string + publishMu sync.Mutex // keeps the follower's entries in offset order // Track last activity for idle cleanup lastActivityTime atomic.Int64 // Unix nano timestamp @@ -75,29 +70,6 @@ func (p *LocalPartition) IsFenced() bool { return p.Fence != nil && p.Fence.IsLost() } -func (p *LocalPartition) Publish(message *mq_pb.DataMessage) error { - if err := p.LogBuffer.AddToBuffer(message); err != nil { - return fmt.Errorf("failed to add message to log buffer: %w", err) - } - p.UpdateActivity() // Track publish activity for idle cleanup - - // maybe send to the follower - if p.publishFolloweMeStream != nil { - // println("recv", string(message.Key), message.TsNs) - if followErr := p.publishFolloweMeStream.Send(&mq_pb.PublishFollowMeRequest{ - Message: &mq_pb.PublishFollowMeRequest_Data{ - Data: message, - }, - }); followErr != nil { - return fmt.Errorf("send to follower %s: %v", p.Follower, followErr) - } - } else { - atomic.StoreInt64(&p.AckTsNs, message.TsNs) - } - - return nil -} - func (p *LocalPartition) Subscribe(clientName string, startPosition log_buffer.MessagePosition, onNoMessageFn func() bool, eachMessageFn log_buffer.EachLogEntryFuncType) error { var processedPosition log_buffer.MessagePosition @@ -258,60 +230,6 @@ func (p *LocalPartition) WaitUntilNoPublishers() { } } -func (p *LocalPartition) MaybeConnectToFollowers(initMessage *mq_pb.PublishMessageRequest_InitMessage, grpcDialOption grpc.DialOption) (err error) { - if p.publishFolloweMeStream != nil { - return nil - } - if initMessage.FollowerBroker == "" { - return nil - } - - p.Follower = initMessage.FollowerBroker - ctx := context.Background() - p.followerGrpcConnection, err = pb.GrpcDial(ctx, p.Follower, true, grpcDialOption) - if err != nil { - return fmt.Errorf("fail to dial %s: %v", p.Follower, err) - } - followerClient := mq_pb.NewSeaweedMessagingClient(p.followerGrpcConnection) - p.publishFolloweMeStream, err = followerClient.PublishFollowMe(ctx) - if err != nil { - return fmt.Errorf("fail to create publish client: %w", err) - } - if err = p.publishFolloweMeStream.Send(&mq_pb.PublishFollowMeRequest{ - Message: &mq_pb.PublishFollowMeRequest_Init{ - Init: &mq_pb.PublishFollowMeRequest_InitMessage{ - Topic: initMessage.Topic, - Partition: initMessage.Partition, - }, - }, - }); err != nil { - return err - } - - // start receiving ack from follower - go func() { - defer func() { - // println("stop receiving ack from follower") - }() - - for { - ack, err := p.publishFolloweMeStream.Recv() - if err != nil { - e, _ := status.FromError(err) - if e.Code() == codes.Canceled { - glog.V(0).Infof("local partition %v follower %v stopped", p.Partition, p.Follower) - return - } - glog.Errorf("Receiving local partition %v follower %s ack: %v", p.Partition, p.Follower, err) - return - } - atomic.StoreInt64(&p.AckTsNs, ack.AckTsNs) - // println("recv ack", ack.AckTsNs) - } - }() - return nil -} - func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) { if p.Publishers.Size() == 0 && p.Subscribers.Size() == 0 { @@ -319,20 +237,7 @@ func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) { for !p.LogBuffer.IsAllFlushed() { time.Sleep(113 * time.Millisecond) } - if p.publishFolloweMeStream != nil { - // send close to the follower - if followErr := p.publishFolloweMeStream.Send(&mq_pb.PublishFollowMeRequest{ - Message: &mq_pb.PublishFollowMeRequest_Close{ - Close: &mq_pb.PublishFollowMeRequest_CloseMessage{}, - }, - }); followErr != nil { - glog.Errorf("Error closing follower stream: %v", followErr) - } - glog.V(4).Infof("closing grpcConnection to follower") - p.followerGrpcConnection.Close() - p.publishFolloweMeStream = nil - p.Follower = "" - } + p.closeReplica() hasShutdown = true } @@ -379,18 +284,24 @@ func (p *LocalPartition) Shutdown() { glog.V(0).Infof("local partition %v shutting down", p.Partition) } -func (p *LocalPartition) NotifyLogFlushed(flushTsNs int64) { - if p.publishFolloweMeStream != nil { - if followErr := p.publishFolloweMeStream.Send(&mq_pb.PublishFollowMeRequest{ - Message: &mq_pb.PublishFollowMeRequest_Flush{ - Flush: &mq_pb.PublishFollowMeRequest_FlushMessage{ - TsNs: flushTsNs, - }, - }, - }); followErr != nil { - glog.Errorf("send follower %s flush message: %v", p.Follower, followErr) - } - // println("notifying", p.Follower, "flushed at", flushTsNs) +// closeReplica tells the follower everything is stored, or, when a flush was +// dropped, breaks the stream so the follower stores its copy instead. +func (p *LocalPartition) closeReplica() { + if p.Replica == nil { + return + } + // a dropped window drops every later one, so the watermark stops below the end + if p.LogBuffer.GetLastFlushedOffset() >= p.LogBuffer.GetOffset()-1 { + p.Replica.Close() + } else { + p.Replica.Abandon() + } +} + +// NotifyLogFlushed tells the follower every entry up to offset is stored. +func (p *LocalPartition) NotifyLogFlushed(offset int64) { + if p.Replica != nil { + p.Replica.Flushed(offset) } } diff --git a/weed/mq/topic/local_partition_offset.go b/weed/mq/topic/local_partition_offset.go index 5b07d25aa8..6d8f336300 100644 --- a/weed/mq/topic/local_partition_offset.go +++ b/weed/mq/topic/local_partition_offset.go @@ -2,7 +2,6 @@ package topic import ( "fmt" - "sync/atomic" "time" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" @@ -11,34 +10,29 @@ import ( ) // PublishWithOffset appends the message and returns the offset the buffer gave it. +// On a replicated partition the entry is queued for the follower in offset order. func (p *LocalPartition) PublishWithOffset(message *mq_pb.DataMessage) (int64, error) { - offset, err := p.addToBuffer(message) + p.publishMu.Lock() + if p.Replica != nil && p.Replica.Err() != nil { + // a broken pair stores nothing new; the publisher resends to the next pair + p.publishMu.Unlock() + return 0, p.Replica.Err() + } + entry, err := p.addToBuffer(message) + if err == nil && p.Replica != nil { + err = p.Replica.Send(entry) + } + p.publishMu.Unlock() if err != nil { - return 0, fmt.Errorf("failed to add message to buffer: %w", err) + return 0, err } - - // Track publish activity for idle cleanup (consistent with Publish method) p.UpdateActivity() - - // Send to follower if needed (same logic as original Publish) - if p.publishFolloweMeStream != nil { - if followErr := p.publishFolloweMeStream.Send(&mq_pb.PublishFollowMeRequest{ - Message: &mq_pb.PublishFollowMeRequest_Data{ - Data: message, - }, - }); followErr != nil { - return 0, fmt.Errorf("send to follower %s: %v", p.Follower, followErr) - } - } else { - atomic.StoreInt64(&p.AckTsNs, message.TsNs) - } - - return offset, nil + return entry.Offset, nil } // addToBuffer has the buffer assign the offset under its own lock, so offsets // stay in append order across publishers. -func (p *LocalPartition) addToBuffer(message *mq_pb.DataMessage) (int64, error) { +func (p *LocalPartition) addToBuffer(message *mq_pb.DataMessage) (*filer_pb.LogEntry, error) { processingTsNs := message.TsNs if processingTsNs == 0 { processingTsNs = time.Now().UnixNano() @@ -51,9 +45,9 @@ func (p *LocalPartition) addToBuffer(message *mq_pb.DataMessage) (int64, error) Offset: -1, } if err := p.LogBuffer.AddLogEntryToBuffer(logEntry); err != nil { - return 0, fmt.Errorf("failed to add log entry to buffer: %w", err) + return nil, fmt.Errorf("failed to add log entry to buffer: %w", err) } - return logEntry.Offset, nil + return logEntry, nil } // GetOffsetInfo returns offset information for this partition diff --git a/weed/mq/topic/partition_fence.go b/weed/mq/topic/partition_fence.go index 0b8b162bcb..8e9d57969f 100644 --- a/weed/mq/topic/partition_fence.go +++ b/weed/mq/topic/partition_fence.go @@ -1,24 +1,44 @@ package topic import ( + "sync" "sync/atomic" ) // PartitionFenceName is the partition directory entry naming the one broker allowed to write it. const PartitionFenceName = ".fence" -// PartitionFence is the fence this broker stored; every write requires its token unchanged. +// PartitionFence is the fence this broker stored; every write requires its current token. type PartitionFence struct { Path string Epoch int64 - Token string + mu sync.Mutex + token string lost atomic.Bool } +func NewPartitionFence(path string, epoch int64, token string) *PartitionFence { + return &PartitionFence{Path: path, Epoch: epoch, token: token} +} + func PartitionFencePath(t Topic, p Partition) string { return PartitionDir(t, p) + "/" + PartitionFenceName } +// Token is the etag of the fence entry as this broker last wrote it. +func (f *PartitionFence) Token() string { + f.mu.Lock() + defer f.mu.Unlock() + return f.token +} + +// Hold replaces the token after this broker rewrote the fence. +func (f *PartitionFence) Hold(token string) { + f.mu.Lock() + defer f.mu.Unlock() + f.token = token +} + // MarkLost records that another broker has taken the fence. func (f *PartitionFence) MarkLost() { f.lost.Store(true) diff --git a/weed/mq/topic/replicator.go b/weed/mq/topic/replicator.go new file mode 100644 index 0000000000..121bda8579 --- /dev/null +++ b/weed/mq/topic/replicator.go @@ -0,0 +1,229 @@ +package topic + +import ( + "context" + "errors" + "fmt" + "io" + "sync" + "sync/atomic" + "time" + + "github.com/seaweedfs/seaweedfs/weed/pb" + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" + "google.golang.org/grpc" +) + +const ( + replicaHeartbeat = time.Second + // replicaTimeout is how long a leader hears nothing from its follower before + // it takes the pair for broken. + replicaTimeout = 5 * time.Second + replicaQueue = 4096 +) + +var ( + // ErrReplicaClosed is the error a replicator reports after a graceful close. + ErrReplicaClosed = errors.New("replica closed") + // ErrReplicaAbandoned is reported after Abandon, which leaves the follower to store its copy. + ErrReplicaAbandoned = errors.New("replica abandoned with unstored entries") +) + +// Replicator streams a leader partition's entries to its follower, in offset +// order, and tracks the highest offset the follower holds. +type Replicator struct { + Follower string + + conn *grpc.ClientConn + stream mq_pb.SeaweedMessaging_PublishFollowMeClient + cancel context.CancelFunc + sendCh chan *mq_pb.PublishFollowMeRequest + closing atomic.Bool + + mu sync.Mutex + acked int64 + err error + changed chan struct{} // closed and replaced whenever acked or err changes + broken chan struct{} + + lastHeard atomic.Int64 +} + +func StartReplicator(follower string, dialOption grpc.DialOption, init *mq_pb.PublishFollowMeRequest_InitMessage) (*Replicator, error) { + ctx, cancel := context.WithCancel(context.Background()) + conn, err := pb.GrpcDial(ctx, follower, false, dialOption) + if err != nil { + cancel() + return nil, fmt.Errorf("dial follower %s: %w", follower, err) + } + stream, err := mq_pb.NewSeaweedMessagingClient(conn).PublishFollowMe(ctx) + if err == nil { + err = stream.Send(&mq_pb.PublishFollowMeRequest{Message: &mq_pb.PublishFollowMeRequest_Init{Init: init}}) + } + if err != nil { + cancel() + conn.Close() + return nil, fmt.Errorf("follow stream to %s: %w", follower, err) + } + r := &Replicator{ + Follower: follower, + conn: conn, + stream: stream, + cancel: cancel, + sendCh: make(chan *mq_pb.PublishFollowMeRequest, replicaQueue), + acked: -1, + changed: make(chan struct{}), + broken: make(chan struct{}), + } + r.lastHeard.Store(time.Now().UnixNano()) + go r.sendLoop() + go r.recvLoop() + go r.watchSilence() + return r, nil +} + +// Send queues an entry for the follower. Callers queue entries in offset order. +func (r *Replicator) Send(entry *filer_pb.LogEntry) error { + select { + case r.sendCh <- &mq_pb.PublishFollowMeRequest{Message: &mq_pb.PublishFollowMeRequest_Entry{Entry: entry}}: + return nil + case <-r.broken: + return r.Err() + } +} + +// Flushed tells the follower every entry up to offset is stored. It never blocks: +// a later notice covers a dropped one. +func (r *Replicator) Flushed(offset int64) { + select { + case r.sendCh <- &mq_pb.PublishFollowMeRequest{Message: &mq_pb.PublishFollowMeRequest_Flush{Flush: &mq_pb.PublishFollowMeRequest_FlushMessage{Offset: offset}}}: + default: + } +} + +// WaitAcked returns once the follower holds offset, or the error that broke the pair. +func (r *Replicator) WaitAcked(offset int64) error { + for { + r.mu.Lock() + acked, err, changed := r.acked, r.err, r.changed + r.mu.Unlock() + if acked >= offset { + return nil + } + if err != nil { + return err + } + <-changed + } +} + +// Broken is closed once the pair breaks or the replicator closes. +func (r *Replicator) Broken() <-chan struct{} { + return r.broken +} + +func (r *Replicator) Err() error { + r.mu.Lock() + defer r.mu.Unlock() + return r.err +} + +// Close ends the stream after every queued entry, telling the follower the +// leader stored everything it holds. +func (r *Replicator) Close() { + if r.closing.Swap(true) { + return + } + select { + case r.sendCh <- &mq_pb.PublishFollowMeRequest{Message: &mq_pb.PublishFollowMeRequest_Close{Close: &mq_pb.PublishFollowMeRequest_CloseMessage{}}}: + case <-r.broken: + } + select { + case <-r.broken: + case <-time.After(replicaTimeout): + r.fail(ErrReplicaClosed) + } +} + +// Abandon breaks the stream without closing it, so the follower takes the +// partition over and stores what this leader could not. +func (r *Replicator) Abandon() { + r.fail(ErrReplicaAbandoned) +} + +func (r *Replicator) sendLoop() { + ticker := time.NewTicker(replicaHeartbeat) + defer ticker.Stop() + heartbeat := &mq_pb.PublishFollowMeRequest{Message: &mq_pb.PublishFollowMeRequest_Heartbeat{Heartbeat: &mq_pb.PublishFollowMeRequest_HeartbeatMessage{}}} + for { + var req *mq_pb.PublishFollowMeRequest + select { + case <-r.broken: + return + case req = <-r.sendCh: + case <-ticker.C: + req = heartbeat + } + if err := r.stream.Send(req); err != nil { + r.fail(fmt.Errorf("send to follower %s: %w", r.Follower, err)) + return + } + if req.GetClose() != nil { + r.stream.CloseSend() + } + } +} + +// watchSilence runs apart from sendLoop, so a send blocked on a follower that +// stopped reading still breaks the pair. +func (r *Replicator) watchSilence() { + ticker := time.NewTicker(replicaHeartbeat) + defer ticker.Stop() + for { + select { + case <-r.broken: + return + case <-ticker.C: + if silent := time.Since(time.Unix(0, r.lastHeard.Load())); silent > replicaTimeout { + r.fail(fmt.Errorf("follower %s silent for %v", r.Follower, silent)) + return + } + } + } +} + +func (r *Replicator) recvLoop() { + for { + resp, err := r.stream.Recv() + if err != nil { + if r.closing.Load() && errors.Is(err, io.EOF) { + r.fail(ErrReplicaClosed) + } else { + r.fail(fmt.Errorf("follower %s: %w", r.Follower, err)) + } + return + } + r.lastHeard.Store(time.Now().UnixNano()) + r.mu.Lock() + if resp.AckOffset > r.acked { + r.acked = resp.AckOffset + close(r.changed) + r.changed = make(chan struct{}) + } + r.mu.Unlock() + } +} + +func (r *Replicator) fail(err error) { + r.mu.Lock() + if r.err == nil { + r.err = err + close(r.changed) + r.changed = make(chan struct{}) + close(r.broken) + } + r.mu.Unlock() + r.cancel() + r.conn.Close() +} diff --git a/weed/pb/mq_broker.proto b/weed/pb/mq_broker.proto index fd27411b0a..d5d6fb8544 100644 --- a/weed/pb/mq_broker.proto +++ b/weed/pb/mq_broker.proto @@ -61,6 +61,9 @@ service SeaweedMessaging { } rpc SubscribeFollowMe (stream SubscribeFollowMeRequest) returns (SubscribeFollowMeResponse) { } + // A broker of a partition's pair reports that the pair broke; the balancer assigns a new pair + rpc EndPartitionGeneration (EndPartitionGenerationRequest) returns (EndPartitionGenerationResponse) { + } // Stateless fetch API (Kafka-style) - request/response pattern // This is the recommended API for Kafka gateway and other stateless clients @@ -304,21 +307,37 @@ message PublishFollowMeRequest { message InitMessage { schema_pb.Topic topic = 1; schema_pb.Partition partition = 2; + int64 epoch = 3; + string leader = 4; } message FlushMessage { int64 ts_ns = 1; + int64 offset = 2; // every entry up to this offset is stored } message CloseMessage { } + message HeartbeatMessage { + } oneof message { InitMessage init = 1; DataMessage data = 2; FlushMessage flush = 3; CloseMessage close = 4; + filer_pb.LogEntry entry = 5; + HeartbeatMessage heartbeat = 6; } } message PublishFollowMeResponse { int64 ack_ts_ns = 1; + int64 ack_offset = 2; // the follower holds every entry up to this offset +} +message EndPartitionGenerationRequest { + schema_pb.Topic topic = 1; + schema_pb.Partition partition = 2; + int64 epoch = 3; + string broker = 4; +} +message EndPartitionGenerationResponse { } message SubscribeMessageRequest { message InitMessage { diff --git a/weed/pb/mq_pb/mq_broker.pb.go b/weed/pb/mq_pb/mq_broker.pb.go index d537ab90bc..5abeb6c54a 100644 --- a/weed/pb/mq_pb/mq_broker.pb.go +++ b/weed/pb/mq_pb/mq_broker.pb.go @@ -2102,6 +2102,8 @@ type PublishFollowMeRequest struct { // *PublishFollowMeRequest_Data // *PublishFollowMeRequest_Flush // *PublishFollowMeRequest_Close + // *PublishFollowMeRequest_Entry + // *PublishFollowMeRequest_Heartbeat Message isPublishFollowMeRequest_Message `protobuf_oneof:"message"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -2180,6 +2182,24 @@ func (x *PublishFollowMeRequest) GetClose() *PublishFollowMeRequest_CloseMessage return nil } +func (x *PublishFollowMeRequest) GetEntry() *filer_pb.LogEntry { + if x != nil { + if x, ok := x.Message.(*PublishFollowMeRequest_Entry); ok { + return x.Entry + } + } + return nil +} + +func (x *PublishFollowMeRequest) GetHeartbeat() *PublishFollowMeRequest_HeartbeatMessage { + if x != nil { + if x, ok := x.Message.(*PublishFollowMeRequest_Heartbeat); ok { + return x.Heartbeat + } + } + return nil +} + type isPublishFollowMeRequest_Message interface { isPublishFollowMeRequest_Message() } @@ -2200,6 +2220,14 @@ type PublishFollowMeRequest_Close struct { Close *PublishFollowMeRequest_CloseMessage `protobuf:"bytes,4,opt,name=close,proto3,oneof"` } +type PublishFollowMeRequest_Entry struct { + Entry *filer_pb.LogEntry `protobuf:"bytes,5,opt,name=entry,proto3,oneof"` +} + +type PublishFollowMeRequest_Heartbeat struct { + Heartbeat *PublishFollowMeRequest_HeartbeatMessage `protobuf:"bytes,6,opt,name=heartbeat,proto3,oneof"` +} + func (*PublishFollowMeRequest_Init) isPublishFollowMeRequest_Message() {} func (*PublishFollowMeRequest_Data) isPublishFollowMeRequest_Message() {} @@ -2208,9 +2236,14 @@ func (*PublishFollowMeRequest_Flush) isPublishFollowMeRequest_Message() {} func (*PublishFollowMeRequest_Close) isPublishFollowMeRequest_Message() {} +func (*PublishFollowMeRequest_Entry) isPublishFollowMeRequest_Message() {} + +func (*PublishFollowMeRequest_Heartbeat) isPublishFollowMeRequest_Message() {} + type PublishFollowMeResponse struct { state protoimpl.MessageState `protogen:"open.v1"` AckTsNs int64 `protobuf:"varint,1,opt,name=ack_ts_ns,json=ackTsNs,proto3" json:"ack_ts_ns,omitempty"` + AckOffset int64 `protobuf:"varint,2,opt,name=ack_offset,json=ackOffset,proto3" json:"ack_offset,omitempty"` // the follower holds every entry up to this offset unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -2252,6 +2285,117 @@ func (x *PublishFollowMeResponse) GetAckTsNs() int64 { return 0 } +func (x *PublishFollowMeResponse) GetAckOffset() int64 { + if x != nil { + return x.AckOffset + } + return 0 +} + +type EndPartitionGenerationRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Topic *schema_pb.Topic `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` + Partition *schema_pb.Partition `protobuf:"bytes,2,opt,name=partition,proto3" json:"partition,omitempty"` + Epoch int64 `protobuf:"varint,3,opt,name=epoch,proto3" json:"epoch,omitempty"` + Broker string `protobuf:"bytes,4,opt,name=broker,proto3" json:"broker,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EndPartitionGenerationRequest) Reset() { + *x = EndPartitionGenerationRequest{} + mi := &file_mq_broker_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EndPartitionGenerationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EndPartitionGenerationRequest) ProtoMessage() {} + +func (x *EndPartitionGenerationRequest) ProtoReflect() protoreflect.Message { + mi := &file_mq_broker_proto_msgTypes[36] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EndPartitionGenerationRequest.ProtoReflect.Descriptor instead. +func (*EndPartitionGenerationRequest) Descriptor() ([]byte, []int) { + return file_mq_broker_proto_rawDescGZIP(), []int{36} +} + +func (x *EndPartitionGenerationRequest) GetTopic() *schema_pb.Topic { + if x != nil { + return x.Topic + } + return nil +} + +func (x *EndPartitionGenerationRequest) GetPartition() *schema_pb.Partition { + if x != nil { + return x.Partition + } + return nil +} + +func (x *EndPartitionGenerationRequest) GetEpoch() int64 { + if x != nil { + return x.Epoch + } + return 0 +} + +func (x *EndPartitionGenerationRequest) GetBroker() string { + if x != nil { + return x.Broker + } + return "" +} + +type EndPartitionGenerationResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EndPartitionGenerationResponse) Reset() { + *x = EndPartitionGenerationResponse{} + mi := &file_mq_broker_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EndPartitionGenerationResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EndPartitionGenerationResponse) ProtoMessage() {} + +func (x *EndPartitionGenerationResponse) ProtoReflect() protoreflect.Message { + mi := &file_mq_broker_proto_msgTypes[37] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EndPartitionGenerationResponse.ProtoReflect.Descriptor instead. +func (*EndPartitionGenerationResponse) Descriptor() ([]byte, []int) { + return file_mq_broker_proto_rawDescGZIP(), []int{37} +} + type SubscribeMessageRequest struct { state protoimpl.MessageState `protogen:"open.v1"` // Types that are valid to be assigned to Message: @@ -2266,7 +2410,7 @@ type SubscribeMessageRequest struct { func (x *SubscribeMessageRequest) Reset() { *x = SubscribeMessageRequest{} - mi := &file_mq_broker_proto_msgTypes[36] + mi := &file_mq_broker_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2278,7 +2422,7 @@ func (x *SubscribeMessageRequest) String() string { func (*SubscribeMessageRequest) ProtoMessage() {} func (x *SubscribeMessageRequest) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[36] + mi := &file_mq_broker_proto_msgTypes[38] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2291,7 +2435,7 @@ func (x *SubscribeMessageRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SubscribeMessageRequest.ProtoReflect.Descriptor instead. func (*SubscribeMessageRequest) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{36} + return file_mq_broker_proto_rawDescGZIP(), []int{38} } func (x *SubscribeMessageRequest) GetMessage() isSubscribeMessageRequest_Message { @@ -2363,7 +2507,7 @@ type SubscribeMessageResponse struct { func (x *SubscribeMessageResponse) Reset() { *x = SubscribeMessageResponse{} - mi := &file_mq_broker_proto_msgTypes[37] + mi := &file_mq_broker_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2375,7 +2519,7 @@ func (x *SubscribeMessageResponse) String() string { func (*SubscribeMessageResponse) ProtoMessage() {} func (x *SubscribeMessageResponse) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[37] + mi := &file_mq_broker_proto_msgTypes[39] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2388,7 +2532,7 @@ func (x *SubscribeMessageResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SubscribeMessageResponse.ProtoReflect.Descriptor instead. func (*SubscribeMessageResponse) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{37} + return file_mq_broker_proto_rawDescGZIP(), []int{39} } func (x *SubscribeMessageResponse) GetMessage() isSubscribeMessageResponse_Message { @@ -2446,7 +2590,7 @@ type SubscribeFollowMeRequest struct { func (x *SubscribeFollowMeRequest) Reset() { *x = SubscribeFollowMeRequest{} - mi := &file_mq_broker_proto_msgTypes[38] + mi := &file_mq_broker_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2458,7 +2602,7 @@ func (x *SubscribeFollowMeRequest) String() string { func (*SubscribeFollowMeRequest) ProtoMessage() {} func (x *SubscribeFollowMeRequest) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[38] + mi := &file_mq_broker_proto_msgTypes[40] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2471,7 +2615,7 @@ func (x *SubscribeFollowMeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SubscribeFollowMeRequest.ProtoReflect.Descriptor instead. func (*SubscribeFollowMeRequest) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{38} + return file_mq_broker_proto_rawDescGZIP(), []int{40} } func (x *SubscribeFollowMeRequest) GetMessage() isSubscribeFollowMeRequest_Message { @@ -2539,7 +2683,7 @@ type SubscribeFollowMeResponse struct { func (x *SubscribeFollowMeResponse) Reset() { *x = SubscribeFollowMeResponse{} - mi := &file_mq_broker_proto_msgTypes[39] + mi := &file_mq_broker_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2551,7 +2695,7 @@ func (x *SubscribeFollowMeResponse) String() string { func (*SubscribeFollowMeResponse) ProtoMessage() {} func (x *SubscribeFollowMeResponse) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[39] + mi := &file_mq_broker_proto_msgTypes[41] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2564,7 +2708,7 @@ func (x *SubscribeFollowMeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SubscribeFollowMeResponse.ProtoReflect.Descriptor instead. func (*SubscribeFollowMeResponse) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{39} + return file_mq_broker_proto_rawDescGZIP(), []int{41} } func (x *SubscribeFollowMeResponse) GetAckTsNs() int64 { @@ -2600,7 +2744,7 @@ type FetchMessageRequest struct { func (x *FetchMessageRequest) Reset() { *x = FetchMessageRequest{} - mi := &file_mq_broker_proto_msgTypes[40] + mi := &file_mq_broker_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2612,7 +2756,7 @@ func (x *FetchMessageRequest) String() string { func (*FetchMessageRequest) ProtoMessage() {} func (x *FetchMessageRequest) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[40] + mi := &file_mq_broker_proto_msgTypes[42] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2625,7 +2769,7 @@ func (x *FetchMessageRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use FetchMessageRequest.ProtoReflect.Descriptor instead. func (*FetchMessageRequest) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{40} + return file_mq_broker_proto_rawDescGZIP(), []int{42} } func (x *FetchMessageRequest) GetTopic() *schema_pb.Topic { @@ -2711,7 +2855,7 @@ type FetchMessageResponse struct { func (x *FetchMessageResponse) Reset() { *x = FetchMessageResponse{} - mi := &file_mq_broker_proto_msgTypes[41] + mi := &file_mq_broker_proto_msgTypes[43] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2723,7 +2867,7 @@ func (x *FetchMessageResponse) String() string { func (*FetchMessageResponse) ProtoMessage() {} func (x *FetchMessageResponse) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[41] + mi := &file_mq_broker_proto_msgTypes[43] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2736,7 +2880,7 @@ func (x *FetchMessageResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use FetchMessageResponse.ProtoReflect.Descriptor instead. func (*FetchMessageResponse) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{41} + return file_mq_broker_proto_rawDescGZIP(), []int{43} } func (x *FetchMessageResponse) GetMessages() []*DataMessage { @@ -2798,7 +2942,7 @@ type ClosePublishersRequest struct { func (x *ClosePublishersRequest) Reset() { *x = ClosePublishersRequest{} - mi := &file_mq_broker_proto_msgTypes[42] + mi := &file_mq_broker_proto_msgTypes[44] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2810,7 +2954,7 @@ func (x *ClosePublishersRequest) String() string { func (*ClosePublishersRequest) ProtoMessage() {} func (x *ClosePublishersRequest) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[42] + mi := &file_mq_broker_proto_msgTypes[44] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2823,7 +2967,7 @@ func (x *ClosePublishersRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ClosePublishersRequest.ProtoReflect.Descriptor instead. func (*ClosePublishersRequest) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{42} + return file_mq_broker_proto_rawDescGZIP(), []int{44} } func (x *ClosePublishersRequest) GetTopic() *schema_pb.Topic { @@ -2848,7 +2992,7 @@ type ClosePublishersResponse struct { func (x *ClosePublishersResponse) Reset() { *x = ClosePublishersResponse{} - mi := &file_mq_broker_proto_msgTypes[43] + mi := &file_mq_broker_proto_msgTypes[45] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2860,7 +3004,7 @@ func (x *ClosePublishersResponse) String() string { func (*ClosePublishersResponse) ProtoMessage() {} func (x *ClosePublishersResponse) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[43] + mi := &file_mq_broker_proto_msgTypes[45] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2873,7 +3017,7 @@ func (x *ClosePublishersResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ClosePublishersResponse.ProtoReflect.Descriptor instead. func (*ClosePublishersResponse) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{43} + return file_mq_broker_proto_rawDescGZIP(), []int{45} } type CloseSubscribersRequest struct { @@ -2886,7 +3030,7 @@ type CloseSubscribersRequest struct { func (x *CloseSubscribersRequest) Reset() { *x = CloseSubscribersRequest{} - mi := &file_mq_broker_proto_msgTypes[44] + mi := &file_mq_broker_proto_msgTypes[46] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2898,7 +3042,7 @@ func (x *CloseSubscribersRequest) String() string { func (*CloseSubscribersRequest) ProtoMessage() {} func (x *CloseSubscribersRequest) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[44] + mi := &file_mq_broker_proto_msgTypes[46] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2911,7 +3055,7 @@ func (x *CloseSubscribersRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CloseSubscribersRequest.ProtoReflect.Descriptor instead. func (*CloseSubscribersRequest) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{44} + return file_mq_broker_proto_rawDescGZIP(), []int{46} } func (x *CloseSubscribersRequest) GetTopic() *schema_pb.Topic { @@ -2936,7 +3080,7 @@ type CloseSubscribersResponse struct { func (x *CloseSubscribersResponse) Reset() { *x = CloseSubscribersResponse{} - mi := &file_mq_broker_proto_msgTypes[45] + mi := &file_mq_broker_proto_msgTypes[47] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2948,7 +3092,7 @@ func (x *CloseSubscribersResponse) String() string { func (*CloseSubscribersResponse) ProtoMessage() {} func (x *CloseSubscribersResponse) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[45] + mi := &file_mq_broker_proto_msgTypes[47] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2961,7 +3105,7 @@ func (x *CloseSubscribersResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CloseSubscribersResponse.ProtoReflect.Descriptor instead. func (*CloseSubscribersResponse) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{45} + return file_mq_broker_proto_rawDescGZIP(), []int{47} } type GetUnflushedMessagesRequest struct { @@ -2975,7 +3119,7 @@ type GetUnflushedMessagesRequest struct { func (x *GetUnflushedMessagesRequest) Reset() { *x = GetUnflushedMessagesRequest{} - mi := &file_mq_broker_proto_msgTypes[46] + mi := &file_mq_broker_proto_msgTypes[48] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2987,7 +3131,7 @@ func (x *GetUnflushedMessagesRequest) String() string { func (*GetUnflushedMessagesRequest) ProtoMessage() {} func (x *GetUnflushedMessagesRequest) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[46] + mi := &file_mq_broker_proto_msgTypes[48] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3000,7 +3144,7 @@ func (x *GetUnflushedMessagesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUnflushedMessagesRequest.ProtoReflect.Descriptor instead. func (*GetUnflushedMessagesRequest) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{46} + return file_mq_broker_proto_rawDescGZIP(), []int{48} } func (x *GetUnflushedMessagesRequest) GetTopic() *schema_pb.Topic { @@ -3035,7 +3179,7 @@ type GetUnflushedMessagesResponse struct { func (x *GetUnflushedMessagesResponse) Reset() { *x = GetUnflushedMessagesResponse{} - mi := &file_mq_broker_proto_msgTypes[47] + mi := &file_mq_broker_proto_msgTypes[49] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3047,7 +3191,7 @@ func (x *GetUnflushedMessagesResponse) String() string { func (*GetUnflushedMessagesResponse) ProtoMessage() {} func (x *GetUnflushedMessagesResponse) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[47] + mi := &file_mq_broker_proto_msgTypes[49] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3060,7 +3204,7 @@ func (x *GetUnflushedMessagesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUnflushedMessagesResponse.ProtoReflect.Descriptor instead. func (*GetUnflushedMessagesResponse) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{47} + return file_mq_broker_proto_rawDescGZIP(), []int{49} } func (x *GetUnflushedMessagesResponse) GetMessage() *filer_pb.LogEntry { @@ -3094,7 +3238,7 @@ type GetPartitionRangeInfoRequest struct { func (x *GetPartitionRangeInfoRequest) Reset() { *x = GetPartitionRangeInfoRequest{} - mi := &file_mq_broker_proto_msgTypes[48] + mi := &file_mq_broker_proto_msgTypes[50] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3106,7 +3250,7 @@ func (x *GetPartitionRangeInfoRequest) String() string { func (*GetPartitionRangeInfoRequest) ProtoMessage() {} func (x *GetPartitionRangeInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[48] + mi := &file_mq_broker_proto_msgTypes[50] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3119,7 +3263,7 @@ func (x *GetPartitionRangeInfoRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPartitionRangeInfoRequest.ProtoReflect.Descriptor instead. func (*GetPartitionRangeInfoRequest) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{48} + return file_mq_broker_proto_rawDescGZIP(), []int{50} } func (x *GetPartitionRangeInfoRequest) GetTopic() *schema_pb.Topic { @@ -3152,7 +3296,7 @@ type GetPartitionRangeInfoResponse struct { func (x *GetPartitionRangeInfoResponse) Reset() { *x = GetPartitionRangeInfoResponse{} - mi := &file_mq_broker_proto_msgTypes[49] + mi := &file_mq_broker_proto_msgTypes[51] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3164,7 +3308,7 @@ func (x *GetPartitionRangeInfoResponse) String() string { func (*GetPartitionRangeInfoResponse) ProtoMessage() {} func (x *GetPartitionRangeInfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[49] + mi := &file_mq_broker_proto_msgTypes[51] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3177,7 +3321,7 @@ func (x *GetPartitionRangeInfoResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPartitionRangeInfoResponse.ProtoReflect.Descriptor instead. func (*GetPartitionRangeInfoResponse) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{49} + return file_mq_broker_proto_rawDescGZIP(), []int{51} } func (x *GetPartitionRangeInfoResponse) GetOffsetRange() *OffsetRangeInfo { @@ -3226,7 +3370,7 @@ type OffsetRangeInfo struct { func (x *OffsetRangeInfo) Reset() { *x = OffsetRangeInfo{} - mi := &file_mq_broker_proto_msgTypes[50] + mi := &file_mq_broker_proto_msgTypes[52] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3238,7 +3382,7 @@ func (x *OffsetRangeInfo) String() string { func (*OffsetRangeInfo) ProtoMessage() {} func (x *OffsetRangeInfo) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[50] + mi := &file_mq_broker_proto_msgTypes[52] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3251,7 +3395,7 @@ func (x *OffsetRangeInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use OffsetRangeInfo.ProtoReflect.Descriptor instead. func (*OffsetRangeInfo) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{50} + return file_mq_broker_proto_rawDescGZIP(), []int{52} } func (x *OffsetRangeInfo) GetEarliestOffset() int64 { @@ -3285,7 +3429,7 @@ type TimestampRangeInfo struct { func (x *TimestampRangeInfo) Reset() { *x = TimestampRangeInfo{} - mi := &file_mq_broker_proto_msgTypes[51] + mi := &file_mq_broker_proto_msgTypes[53] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3297,7 +3441,7 @@ func (x *TimestampRangeInfo) String() string { func (*TimestampRangeInfo) ProtoMessage() {} func (x *TimestampRangeInfo) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[51] + mi := &file_mq_broker_proto_msgTypes[53] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3310,7 +3454,7 @@ func (x *TimestampRangeInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use TimestampRangeInfo.ProtoReflect.Descriptor instead. func (*TimestampRangeInfo) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{51} + return file_mq_broker_proto_rawDescGZIP(), []int{53} } func (x *TimestampRangeInfo) GetEarliestTimestampNs() int64 { @@ -3336,7 +3480,7 @@ type PublisherToPubBalancerRequest_InitMessage struct { func (x *PublisherToPubBalancerRequest_InitMessage) Reset() { *x = PublisherToPubBalancerRequest_InitMessage{} - mi := &file_mq_broker_proto_msgTypes[53] + mi := &file_mq_broker_proto_msgTypes[55] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3348,7 +3492,7 @@ func (x *PublisherToPubBalancerRequest_InitMessage) String() string { func (*PublisherToPubBalancerRequest_InitMessage) ProtoMessage() {} func (x *PublisherToPubBalancerRequest_InitMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[53] + mi := &file_mq_broker_proto_msgTypes[55] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3392,7 +3536,7 @@ type SubscriberToSubCoordinatorRequest_InitMessage struct { func (x *SubscriberToSubCoordinatorRequest_InitMessage) Reset() { *x = SubscriberToSubCoordinatorRequest_InitMessage{} - mi := &file_mq_broker_proto_msgTypes[54] + mi := &file_mq_broker_proto_msgTypes[56] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3404,7 +3548,7 @@ func (x *SubscriberToSubCoordinatorRequest_InitMessage) String() string { func (*SubscriberToSubCoordinatorRequest_InitMessage) ProtoMessage() {} func (x *SubscriberToSubCoordinatorRequest_InitMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[54] + mi := &file_mq_broker_proto_msgTypes[56] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3464,7 +3608,7 @@ type SubscriberToSubCoordinatorRequest_AckUnAssignmentMessage struct { func (x *SubscriberToSubCoordinatorRequest_AckUnAssignmentMessage) Reset() { *x = SubscriberToSubCoordinatorRequest_AckUnAssignmentMessage{} - mi := &file_mq_broker_proto_msgTypes[55] + mi := &file_mq_broker_proto_msgTypes[57] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3476,7 +3620,7 @@ func (x *SubscriberToSubCoordinatorRequest_AckUnAssignmentMessage) String() stri func (*SubscriberToSubCoordinatorRequest_AckUnAssignmentMessage) ProtoMessage() {} func (x *SubscriberToSubCoordinatorRequest_AckUnAssignmentMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[55] + mi := &file_mq_broker_proto_msgTypes[57] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3508,7 +3652,7 @@ type SubscriberToSubCoordinatorRequest_AckAssignmentMessage struct { func (x *SubscriberToSubCoordinatorRequest_AckAssignmentMessage) Reset() { *x = SubscriberToSubCoordinatorRequest_AckAssignmentMessage{} - mi := &file_mq_broker_proto_msgTypes[56] + mi := &file_mq_broker_proto_msgTypes[58] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3520,7 +3664,7 @@ func (x *SubscriberToSubCoordinatorRequest_AckAssignmentMessage) String() string func (*SubscriberToSubCoordinatorRequest_AckAssignmentMessage) ProtoMessage() {} func (x *SubscriberToSubCoordinatorRequest_AckAssignmentMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[56] + mi := &file_mq_broker_proto_msgTypes[58] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3552,7 +3696,7 @@ type SubscriberToSubCoordinatorResponse_Assignment struct { func (x *SubscriberToSubCoordinatorResponse_Assignment) Reset() { *x = SubscriberToSubCoordinatorResponse_Assignment{} - mi := &file_mq_broker_proto_msgTypes[57] + mi := &file_mq_broker_proto_msgTypes[59] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3564,7 +3708,7 @@ func (x *SubscriberToSubCoordinatorResponse_Assignment) String() string { func (*SubscriberToSubCoordinatorResponse_Assignment) ProtoMessage() {} func (x *SubscriberToSubCoordinatorResponse_Assignment) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[57] + mi := &file_mq_broker_proto_msgTypes[59] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3596,7 +3740,7 @@ type SubscriberToSubCoordinatorResponse_UnAssignment struct { func (x *SubscriberToSubCoordinatorResponse_UnAssignment) Reset() { *x = SubscriberToSubCoordinatorResponse_UnAssignment{} - mi := &file_mq_broker_proto_msgTypes[58] + mi := &file_mq_broker_proto_msgTypes[60] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3608,7 +3752,7 @@ func (x *SubscriberToSubCoordinatorResponse_UnAssignment) String() string { func (*SubscriberToSubCoordinatorResponse_UnAssignment) ProtoMessage() {} func (x *SubscriberToSubCoordinatorResponse_UnAssignment) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[58] + mi := &file_mq_broker_proto_msgTypes[60] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3644,7 +3788,7 @@ type PublishMessageRequest_InitMessage struct { func (x *PublishMessageRequest_InitMessage) Reset() { *x = PublishMessageRequest_InitMessage{} - mi := &file_mq_broker_proto_msgTypes[59] + mi := &file_mq_broker_proto_msgTypes[61] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3656,7 +3800,7 @@ func (x *PublishMessageRequest_InitMessage) String() string { func (*PublishMessageRequest_InitMessage) ProtoMessage() {} func (x *PublishMessageRequest_InitMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[59] + mi := &file_mq_broker_proto_msgTypes[61] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3711,13 +3855,15 @@ type PublishFollowMeRequest_InitMessage struct { state protoimpl.MessageState `protogen:"open.v1"` Topic *schema_pb.Topic `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` Partition *schema_pb.Partition `protobuf:"bytes,2,opt,name=partition,proto3" json:"partition,omitempty"` + Epoch int64 `protobuf:"varint,3,opt,name=epoch,proto3" json:"epoch,omitempty"` + Leader string `protobuf:"bytes,4,opt,name=leader,proto3" json:"leader,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *PublishFollowMeRequest_InitMessage) Reset() { *x = PublishFollowMeRequest_InitMessage{} - mi := &file_mq_broker_proto_msgTypes[60] + mi := &file_mq_broker_proto_msgTypes[62] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3729,7 +3875,7 @@ func (x *PublishFollowMeRequest_InitMessage) String() string { func (*PublishFollowMeRequest_InitMessage) ProtoMessage() {} func (x *PublishFollowMeRequest_InitMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[60] + mi := &file_mq_broker_proto_msgTypes[62] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3759,16 +3905,31 @@ func (x *PublishFollowMeRequest_InitMessage) GetPartition() *schema_pb.Partition return nil } +func (x *PublishFollowMeRequest_InitMessage) GetEpoch() int64 { + if x != nil { + return x.Epoch + } + return 0 +} + +func (x *PublishFollowMeRequest_InitMessage) GetLeader() string { + if x != nil { + return x.Leader + } + return "" +} + type PublishFollowMeRequest_FlushMessage struct { state protoimpl.MessageState `protogen:"open.v1"` TsNs int64 `protobuf:"varint,1,opt,name=ts_ns,json=tsNs,proto3" json:"ts_ns,omitempty"` + Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` // every entry up to this offset is stored unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *PublishFollowMeRequest_FlushMessage) Reset() { *x = PublishFollowMeRequest_FlushMessage{} - mi := &file_mq_broker_proto_msgTypes[61] + mi := &file_mq_broker_proto_msgTypes[63] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3780,7 +3941,7 @@ func (x *PublishFollowMeRequest_FlushMessage) String() string { func (*PublishFollowMeRequest_FlushMessage) ProtoMessage() {} func (x *PublishFollowMeRequest_FlushMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[61] + mi := &file_mq_broker_proto_msgTypes[63] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3803,6 +3964,13 @@ func (x *PublishFollowMeRequest_FlushMessage) GetTsNs() int64 { return 0 } +func (x *PublishFollowMeRequest_FlushMessage) GetOffset() int64 { + if x != nil { + return x.Offset + } + return 0 +} + type PublishFollowMeRequest_CloseMessage struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -3811,7 +3979,7 @@ type PublishFollowMeRequest_CloseMessage struct { func (x *PublishFollowMeRequest_CloseMessage) Reset() { *x = PublishFollowMeRequest_CloseMessage{} - mi := &file_mq_broker_proto_msgTypes[62] + mi := &file_mq_broker_proto_msgTypes[64] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3823,7 +3991,7 @@ func (x *PublishFollowMeRequest_CloseMessage) String() string { func (*PublishFollowMeRequest_CloseMessage) ProtoMessage() {} func (x *PublishFollowMeRequest_CloseMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[62] + mi := &file_mq_broker_proto_msgTypes[64] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3839,6 +4007,42 @@ func (*PublishFollowMeRequest_CloseMessage) Descriptor() ([]byte, []int) { return file_mq_broker_proto_rawDescGZIP(), []int{34, 2} } +type PublishFollowMeRequest_HeartbeatMessage struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PublishFollowMeRequest_HeartbeatMessage) Reset() { + *x = PublishFollowMeRequest_HeartbeatMessage{} + mi := &file_mq_broker_proto_msgTypes[65] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PublishFollowMeRequest_HeartbeatMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PublishFollowMeRequest_HeartbeatMessage) ProtoMessage() {} + +func (x *PublishFollowMeRequest_HeartbeatMessage) ProtoReflect() protoreflect.Message { + mi := &file_mq_broker_proto_msgTypes[65] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PublishFollowMeRequest_HeartbeatMessage.ProtoReflect.Descriptor instead. +func (*PublishFollowMeRequest_HeartbeatMessage) Descriptor() ([]byte, []int) { + return file_mq_broker_proto_rawDescGZIP(), []int{34, 3} +} + type SubscribeMessageRequest_InitMessage struct { state protoimpl.MessageState `protogen:"open.v1"` ConsumerGroup string `protobuf:"bytes,1,opt,name=consumer_group,json=consumerGroup,proto3" json:"consumer_group,omitempty"` @@ -3856,7 +4060,7 @@ type SubscribeMessageRequest_InitMessage struct { func (x *SubscribeMessageRequest_InitMessage) Reset() { *x = SubscribeMessageRequest_InitMessage{} - mi := &file_mq_broker_proto_msgTypes[63] + mi := &file_mq_broker_proto_msgTypes[66] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3868,7 +4072,7 @@ func (x *SubscribeMessageRequest_InitMessage) String() string { func (*SubscribeMessageRequest_InitMessage) ProtoMessage() {} func (x *SubscribeMessageRequest_InitMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[63] + mi := &file_mq_broker_proto_msgTypes[66] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3881,7 +4085,7 @@ func (x *SubscribeMessageRequest_InitMessage) ProtoReflect() protoreflect.Messag // Deprecated: Use SubscribeMessageRequest_InitMessage.ProtoReflect.Descriptor instead. func (*SubscribeMessageRequest_InitMessage) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{36, 0} + return file_mq_broker_proto_rawDescGZIP(), []int{38, 0} } func (x *SubscribeMessageRequest_InitMessage) GetConsumerGroup() string { @@ -3957,7 +4161,7 @@ type SubscribeMessageRequest_AckMessage struct { func (x *SubscribeMessageRequest_AckMessage) Reset() { *x = SubscribeMessageRequest_AckMessage{} - mi := &file_mq_broker_proto_msgTypes[64] + mi := &file_mq_broker_proto_msgTypes[67] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3969,7 +4173,7 @@ func (x *SubscribeMessageRequest_AckMessage) String() string { func (*SubscribeMessageRequest_AckMessage) ProtoMessage() {} func (x *SubscribeMessageRequest_AckMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[64] + mi := &file_mq_broker_proto_msgTypes[67] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3982,7 +4186,7 @@ func (x *SubscribeMessageRequest_AckMessage) ProtoReflect() protoreflect.Message // Deprecated: Use SubscribeMessageRequest_AckMessage.ProtoReflect.Descriptor instead. func (*SubscribeMessageRequest_AckMessage) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{36, 1} + return file_mq_broker_proto_rawDescGZIP(), []int{38, 1} } func (x *SubscribeMessageRequest_AckMessage) GetTsNs() int64 { @@ -4009,7 +4213,7 @@ type SubscribeMessageRequest_SeekMessage struct { func (x *SubscribeMessageRequest_SeekMessage) Reset() { *x = SubscribeMessageRequest_SeekMessage{} - mi := &file_mq_broker_proto_msgTypes[65] + mi := &file_mq_broker_proto_msgTypes[68] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4021,7 +4225,7 @@ func (x *SubscribeMessageRequest_SeekMessage) String() string { func (*SubscribeMessageRequest_SeekMessage) ProtoMessage() {} func (x *SubscribeMessageRequest_SeekMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[65] + mi := &file_mq_broker_proto_msgTypes[68] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4034,7 +4238,7 @@ func (x *SubscribeMessageRequest_SeekMessage) ProtoReflect() protoreflect.Messag // Deprecated: Use SubscribeMessageRequest_SeekMessage.ProtoReflect.Descriptor instead. func (*SubscribeMessageRequest_SeekMessage) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{36, 2} + return file_mq_broker_proto_rawDescGZIP(), []int{38, 2} } func (x *SubscribeMessageRequest_SeekMessage) GetOffset() int64 { @@ -4062,7 +4266,7 @@ type SubscribeMessageResponse_SubscribeCtrlMessage struct { func (x *SubscribeMessageResponse_SubscribeCtrlMessage) Reset() { *x = SubscribeMessageResponse_SubscribeCtrlMessage{} - mi := &file_mq_broker_proto_msgTypes[66] + mi := &file_mq_broker_proto_msgTypes[69] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4074,7 +4278,7 @@ func (x *SubscribeMessageResponse_SubscribeCtrlMessage) String() string { func (*SubscribeMessageResponse_SubscribeCtrlMessage) ProtoMessage() {} func (x *SubscribeMessageResponse_SubscribeCtrlMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[66] + mi := &file_mq_broker_proto_msgTypes[69] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4087,7 +4291,7 @@ func (x *SubscribeMessageResponse_SubscribeCtrlMessage) ProtoReflect() protorefl // Deprecated: Use SubscribeMessageResponse_SubscribeCtrlMessage.ProtoReflect.Descriptor instead. func (*SubscribeMessageResponse_SubscribeCtrlMessage) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{37, 0} + return file_mq_broker_proto_rawDescGZIP(), []int{39, 0} } func (x *SubscribeMessageResponse_SubscribeCtrlMessage) GetError() string { @@ -4122,7 +4326,7 @@ type SubscribeFollowMeRequest_InitMessage struct { func (x *SubscribeFollowMeRequest_InitMessage) Reset() { *x = SubscribeFollowMeRequest_InitMessage{} - mi := &file_mq_broker_proto_msgTypes[67] + mi := &file_mq_broker_proto_msgTypes[70] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4134,7 +4338,7 @@ func (x *SubscribeFollowMeRequest_InitMessage) String() string { func (*SubscribeFollowMeRequest_InitMessage) ProtoMessage() {} func (x *SubscribeFollowMeRequest_InitMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[67] + mi := &file_mq_broker_proto_msgTypes[70] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4147,7 +4351,7 @@ func (x *SubscribeFollowMeRequest_InitMessage) ProtoReflect() protoreflect.Messa // Deprecated: Use SubscribeFollowMeRequest_InitMessage.ProtoReflect.Descriptor instead. func (*SubscribeFollowMeRequest_InitMessage) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{38, 0} + return file_mq_broker_proto_rawDescGZIP(), []int{40, 0} } func (x *SubscribeFollowMeRequest_InitMessage) GetTopic() *schema_pb.Topic { @@ -4180,7 +4384,7 @@ type SubscribeFollowMeRequest_AckMessage struct { func (x *SubscribeFollowMeRequest_AckMessage) Reset() { *x = SubscribeFollowMeRequest_AckMessage{} - mi := &file_mq_broker_proto_msgTypes[68] + mi := &file_mq_broker_proto_msgTypes[71] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4192,7 +4396,7 @@ func (x *SubscribeFollowMeRequest_AckMessage) String() string { func (*SubscribeFollowMeRequest_AckMessage) ProtoMessage() {} func (x *SubscribeFollowMeRequest_AckMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[68] + mi := &file_mq_broker_proto_msgTypes[71] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4205,7 +4409,7 @@ func (x *SubscribeFollowMeRequest_AckMessage) ProtoReflect() protoreflect.Messag // Deprecated: Use SubscribeFollowMeRequest_AckMessage.ProtoReflect.Descriptor instead. func (*SubscribeFollowMeRequest_AckMessage) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{38, 1} + return file_mq_broker_proto_rawDescGZIP(), []int{40, 1} } func (x *SubscribeFollowMeRequest_AckMessage) GetTsNs() int64 { @@ -4223,7 +4427,7 @@ type SubscribeFollowMeRequest_CloseMessage struct { func (x *SubscribeFollowMeRequest_CloseMessage) Reset() { *x = SubscribeFollowMeRequest_CloseMessage{} - mi := &file_mq_broker_proto_msgTypes[69] + mi := &file_mq_broker_proto_msgTypes[72] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4235,7 +4439,7 @@ func (x *SubscribeFollowMeRequest_CloseMessage) String() string { func (*SubscribeFollowMeRequest_CloseMessage) ProtoMessage() {} func (x *SubscribeFollowMeRequest_CloseMessage) ProtoReflect() protoreflect.Message { - mi := &file_mq_broker_proto_msgTypes[69] + mi := &file_mq_broker_proto_msgTypes[72] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4248,7 +4452,7 @@ func (x *SubscribeFollowMeRequest_CloseMessage) ProtoReflect() protoreflect.Mess // Deprecated: Use SubscribeFollowMeRequest_CloseMessage.ProtoReflect.Descriptor instead. func (*SubscribeFollowMeRequest_CloseMessage) Descriptor() ([]byte, []int) { - return file_mq_broker_proto_rawDescGZIP(), []int{38, 2} + return file_mq_broker_proto_rawDescGZIP(), []int{40, 2} } var File_mq_broker_proto protoreflect.FileDescriptor @@ -4421,21 +4625,35 @@ const file_mq_broker_proto_rawDesc = "" + "\fshould_close\x18\x03 \x01(\bR\vshouldClose\x12\x1d\n" + "\n" + "error_code\x18\x04 \x01(\x05R\terrorCode\x12'\n" + - "\x0fassigned_offset\x18\x05 \x01(\x03R\x0eassignedOffset\"\xd2\x03\n" + + "\x0fassigned_offset\x18\x05 \x01(\x03R\x0eassignedOffset\"\xb0\x05\n" + "\x16PublishFollowMeRequest\x12F\n" + "\x04init\x18\x01 \x01(\v20.messaging_pb.PublishFollowMeRequest.InitMessageH\x00R\x04init\x12/\n" + "\x04data\x18\x02 \x01(\v2\x19.messaging_pb.DataMessageH\x00R\x04data\x12I\n" + "\x05flush\x18\x03 \x01(\v21.messaging_pb.PublishFollowMeRequest.FlushMessageH\x00R\x05flush\x12I\n" + - "\x05close\x18\x04 \x01(\v21.messaging_pb.PublishFollowMeRequest.CloseMessageH\x00R\x05close\x1ai\n" + + "\x05close\x18\x04 \x01(\v21.messaging_pb.PublishFollowMeRequest.CloseMessageH\x00R\x05close\x12*\n" + + "\x05entry\x18\x05 \x01(\v2\x12.filer_pb.LogEntryH\x00R\x05entry\x12U\n" + + "\theartbeat\x18\x06 \x01(\v25.messaging_pb.PublishFollowMeRequest.HeartbeatMessageH\x00R\theartbeat\x1a\x97\x01\n" + "\vInitMessage\x12&\n" + "\x05topic\x18\x01 \x01(\v2\x10.schema_pb.TopicR\x05topic\x122\n" + - "\tpartition\x18\x02 \x01(\v2\x14.schema_pb.PartitionR\tpartition\x1a#\n" + + "\tpartition\x18\x02 \x01(\v2\x14.schema_pb.PartitionR\tpartition\x12\x14\n" + + "\x05epoch\x18\x03 \x01(\x03R\x05epoch\x12\x16\n" + + "\x06leader\x18\x04 \x01(\tR\x06leader\x1a;\n" + "\fFlushMessage\x12\x13\n" + - "\x05ts_ns\x18\x01 \x01(\x03R\x04tsNs\x1a\x0e\n" + - "\fCloseMessageB\t\n" + - "\amessage\"5\n" + + "\x05ts_ns\x18\x01 \x01(\x03R\x04tsNs\x12\x16\n" + + "\x06offset\x18\x02 \x01(\x03R\x06offset\x1a\x0e\n" + + "\fCloseMessage\x1a\x12\n" + + "\x10HeartbeatMessageB\t\n" + + "\amessage\"T\n" + "\x17PublishFollowMeResponse\x12\x1a\n" + - "\tack_ts_ns\x18\x01 \x01(\x03R\aackTsNs\"\x9d\x06\n" + + "\tack_ts_ns\x18\x01 \x01(\x03R\aackTsNs\x12\x1d\n" + + "\n" + + "ack_offset\x18\x02 \x01(\x03R\tackOffset\"\xa9\x01\n" + + "\x1dEndPartitionGenerationRequest\x12&\n" + + "\x05topic\x18\x01 \x01(\v2\x10.schema_pb.TopicR\x05topic\x122\n" + + "\tpartition\x18\x02 \x01(\v2\x14.schema_pb.PartitionR\tpartition\x12\x14\n" + + "\x05epoch\x18\x03 \x01(\x03R\x05epoch\x12\x16\n" + + "\x06broker\x18\x04 \x01(\tR\x06broker\" \n" + + "\x1eEndPartitionGenerationResponse\"\x9d\x06\n" + "\x17SubscribeMessageRequest\x12G\n" + "\x04init\x18\x01 \x01(\v21.messaging_pb.SubscribeMessageRequest.InitMessageH\x00R\x04init\x12D\n" + "\x03ack\x18\x02 \x01(\v20.messaging_pb.SubscribeMessageRequest.AckMessageH\x00R\x03ack\x12G\n" + @@ -4540,7 +4758,7 @@ const file_mq_broker_proto_rawDesc = "" + "\x0fhigh_water_mark\x18\x03 \x01(\x03R\rhighWaterMark\"x\n" + "\x12TimestampRangeInfo\x122\n" + "\x15earliest_timestamp_ns\x18\x01 \x01(\x03R\x13earliestTimestampNs\x12.\n" + - "\x13latest_timestamp_ns\x18\x02 \x01(\x03R\x11latestTimestampNs2\xad\x11\n" + + "\x13latest_timestamp_ns\x18\x02 \x01(\x03R\x11latestTimestampNs2\xa4\x12\n" + "\x10SeaweedMessaging\x12c\n" + "\x10FindBrokerLeader\x12%.messaging_pb.FindBrokerLeaderRequest\x1a&.messaging_pb.FindBrokerLeaderResponse\"\x00\x12y\n" + "\x16PublisherToPubBalancer\x12+.messaging_pb.PublisherToPubBalancerRequest\x1a,.messaging_pb.PublisherToPubBalancerResponse\"\x00(\x010\x01\x12Z\n" + @@ -4560,7 +4778,8 @@ const file_mq_broker_proto_rawDesc = "" + "\x0ePublishMessage\x12#.messaging_pb.PublishMessageRequest\x1a$.messaging_pb.PublishMessageResponse\"\x00(\x010\x01\x12g\n" + "\x10SubscribeMessage\x12%.messaging_pb.SubscribeMessageRequest\x1a&.messaging_pb.SubscribeMessageResponse\"\x00(\x010\x01\x12d\n" + "\x0fPublishFollowMe\x12$.messaging_pb.PublishFollowMeRequest\x1a%.messaging_pb.PublishFollowMeResponse\"\x00(\x010\x01\x12h\n" + - "\x11SubscribeFollowMe\x12&.messaging_pb.SubscribeFollowMeRequest\x1a'.messaging_pb.SubscribeFollowMeResponse\"\x00(\x01\x12W\n" + + "\x11SubscribeFollowMe\x12&.messaging_pb.SubscribeFollowMeRequest\x1a'.messaging_pb.SubscribeFollowMeResponse\"\x00(\x01\x12u\n" + + "\x16EndPartitionGeneration\x12+.messaging_pb.EndPartitionGenerationRequest\x1a,.messaging_pb.EndPartitionGenerationResponse\"\x00\x12W\n" + "\fFetchMessage\x12!.messaging_pb.FetchMessageRequest\x1a\".messaging_pb.FetchMessageResponse\"\x00\x12q\n" + "\x14GetUnflushedMessages\x12).messaging_pb.GetUnflushedMessagesRequest\x1a*.messaging_pb.GetUnflushedMessagesResponse\"\x000\x01\x12r\n" + "\x15GetPartitionRangeInfo\x12*.messaging_pb.GetPartitionRangeInfoRequest\x1a+.messaging_pb.GetPartitionRangeInfoResponse\"\x00BO\n" + @@ -4578,7 +4797,7 @@ func file_mq_broker_proto_rawDescGZIP() []byte { return file_mq_broker_proto_rawDescData } -var file_mq_broker_proto_msgTypes = make([]protoimpl.MessageInfo, 70) +var file_mq_broker_proto_msgTypes = make([]protoimpl.MessageInfo, 73) var file_mq_broker_proto_goTypes = []any{ (*FindBrokerLeaderRequest)(nil), // 0: messaging_pb.FindBrokerLeaderRequest (*FindBrokerLeaderResponse)(nil), // 1: messaging_pb.FindBrokerLeaderResponse @@ -4616,173 +4835,182 @@ var file_mq_broker_proto_goTypes = []any{ (*PublishMessageResponse)(nil), // 33: messaging_pb.PublishMessageResponse (*PublishFollowMeRequest)(nil), // 34: messaging_pb.PublishFollowMeRequest (*PublishFollowMeResponse)(nil), // 35: messaging_pb.PublishFollowMeResponse - (*SubscribeMessageRequest)(nil), // 36: messaging_pb.SubscribeMessageRequest - (*SubscribeMessageResponse)(nil), // 37: messaging_pb.SubscribeMessageResponse - (*SubscribeFollowMeRequest)(nil), // 38: messaging_pb.SubscribeFollowMeRequest - (*SubscribeFollowMeResponse)(nil), // 39: messaging_pb.SubscribeFollowMeResponse - (*FetchMessageRequest)(nil), // 40: messaging_pb.FetchMessageRequest - (*FetchMessageResponse)(nil), // 41: messaging_pb.FetchMessageResponse - (*ClosePublishersRequest)(nil), // 42: messaging_pb.ClosePublishersRequest - (*ClosePublishersResponse)(nil), // 43: messaging_pb.ClosePublishersResponse - (*CloseSubscribersRequest)(nil), // 44: messaging_pb.CloseSubscribersRequest - (*CloseSubscribersResponse)(nil), // 45: messaging_pb.CloseSubscribersResponse - (*GetUnflushedMessagesRequest)(nil), // 46: messaging_pb.GetUnflushedMessagesRequest - (*GetUnflushedMessagesResponse)(nil), // 47: messaging_pb.GetUnflushedMessagesResponse - (*GetPartitionRangeInfoRequest)(nil), // 48: messaging_pb.GetPartitionRangeInfoRequest - (*GetPartitionRangeInfoResponse)(nil), // 49: messaging_pb.GetPartitionRangeInfoResponse - (*OffsetRangeInfo)(nil), // 50: messaging_pb.OffsetRangeInfo - (*TimestampRangeInfo)(nil), // 51: messaging_pb.TimestampRangeInfo - nil, // 52: messaging_pb.BrokerStats.StatsEntry - (*PublisherToPubBalancerRequest_InitMessage)(nil), // 53: messaging_pb.PublisherToPubBalancerRequest.InitMessage - (*SubscriberToSubCoordinatorRequest_InitMessage)(nil), // 54: messaging_pb.SubscriberToSubCoordinatorRequest.InitMessage - (*SubscriberToSubCoordinatorRequest_AckUnAssignmentMessage)(nil), // 55: messaging_pb.SubscriberToSubCoordinatorRequest.AckUnAssignmentMessage - (*SubscriberToSubCoordinatorRequest_AckAssignmentMessage)(nil), // 56: messaging_pb.SubscriberToSubCoordinatorRequest.AckAssignmentMessage - (*SubscriberToSubCoordinatorResponse_Assignment)(nil), // 57: messaging_pb.SubscriberToSubCoordinatorResponse.Assignment - (*SubscriberToSubCoordinatorResponse_UnAssignment)(nil), // 58: messaging_pb.SubscriberToSubCoordinatorResponse.UnAssignment - (*PublishMessageRequest_InitMessage)(nil), // 59: messaging_pb.PublishMessageRequest.InitMessage - (*PublishFollowMeRequest_InitMessage)(nil), // 60: messaging_pb.PublishFollowMeRequest.InitMessage - (*PublishFollowMeRequest_FlushMessage)(nil), // 61: messaging_pb.PublishFollowMeRequest.FlushMessage - (*PublishFollowMeRequest_CloseMessage)(nil), // 62: messaging_pb.PublishFollowMeRequest.CloseMessage - (*SubscribeMessageRequest_InitMessage)(nil), // 63: messaging_pb.SubscribeMessageRequest.InitMessage - (*SubscribeMessageRequest_AckMessage)(nil), // 64: messaging_pb.SubscribeMessageRequest.AckMessage - (*SubscribeMessageRequest_SeekMessage)(nil), // 65: messaging_pb.SubscribeMessageRequest.SeekMessage - (*SubscribeMessageResponse_SubscribeCtrlMessage)(nil), // 66: messaging_pb.SubscribeMessageResponse.SubscribeCtrlMessage - (*SubscribeFollowMeRequest_InitMessage)(nil), // 67: messaging_pb.SubscribeFollowMeRequest.InitMessage - (*SubscribeFollowMeRequest_AckMessage)(nil), // 68: messaging_pb.SubscribeFollowMeRequest.AckMessage - (*SubscribeFollowMeRequest_CloseMessage)(nil), // 69: messaging_pb.SubscribeFollowMeRequest.CloseMessage - (*schema_pb.Topic)(nil), // 70: schema_pb.Topic - (*schema_pb.Partition)(nil), // 71: schema_pb.Partition - (*schema_pb.RecordType)(nil), // 72: schema_pb.RecordType - (*filer_pb.LogEntry)(nil), // 73: filer_pb.LogEntry - (*schema_pb.PartitionOffset)(nil), // 74: schema_pb.PartitionOffset - (schema_pb.OffsetType)(0), // 75: schema_pb.OffsetType + (*EndPartitionGenerationRequest)(nil), // 36: messaging_pb.EndPartitionGenerationRequest + (*EndPartitionGenerationResponse)(nil), // 37: messaging_pb.EndPartitionGenerationResponse + (*SubscribeMessageRequest)(nil), // 38: messaging_pb.SubscribeMessageRequest + (*SubscribeMessageResponse)(nil), // 39: messaging_pb.SubscribeMessageResponse + (*SubscribeFollowMeRequest)(nil), // 40: messaging_pb.SubscribeFollowMeRequest + (*SubscribeFollowMeResponse)(nil), // 41: messaging_pb.SubscribeFollowMeResponse + (*FetchMessageRequest)(nil), // 42: messaging_pb.FetchMessageRequest + (*FetchMessageResponse)(nil), // 43: messaging_pb.FetchMessageResponse + (*ClosePublishersRequest)(nil), // 44: messaging_pb.ClosePublishersRequest + (*ClosePublishersResponse)(nil), // 45: messaging_pb.ClosePublishersResponse + (*CloseSubscribersRequest)(nil), // 46: messaging_pb.CloseSubscribersRequest + (*CloseSubscribersResponse)(nil), // 47: messaging_pb.CloseSubscribersResponse + (*GetUnflushedMessagesRequest)(nil), // 48: messaging_pb.GetUnflushedMessagesRequest + (*GetUnflushedMessagesResponse)(nil), // 49: messaging_pb.GetUnflushedMessagesResponse + (*GetPartitionRangeInfoRequest)(nil), // 50: messaging_pb.GetPartitionRangeInfoRequest + (*GetPartitionRangeInfoResponse)(nil), // 51: messaging_pb.GetPartitionRangeInfoResponse + (*OffsetRangeInfo)(nil), // 52: messaging_pb.OffsetRangeInfo + (*TimestampRangeInfo)(nil), // 53: messaging_pb.TimestampRangeInfo + nil, // 54: messaging_pb.BrokerStats.StatsEntry + (*PublisherToPubBalancerRequest_InitMessage)(nil), // 55: messaging_pb.PublisherToPubBalancerRequest.InitMessage + (*SubscriberToSubCoordinatorRequest_InitMessage)(nil), // 56: messaging_pb.SubscriberToSubCoordinatorRequest.InitMessage + (*SubscriberToSubCoordinatorRequest_AckUnAssignmentMessage)(nil), // 57: messaging_pb.SubscriberToSubCoordinatorRequest.AckUnAssignmentMessage + (*SubscriberToSubCoordinatorRequest_AckAssignmentMessage)(nil), // 58: messaging_pb.SubscriberToSubCoordinatorRequest.AckAssignmentMessage + (*SubscriberToSubCoordinatorResponse_Assignment)(nil), // 59: messaging_pb.SubscriberToSubCoordinatorResponse.Assignment + (*SubscriberToSubCoordinatorResponse_UnAssignment)(nil), // 60: messaging_pb.SubscriberToSubCoordinatorResponse.UnAssignment + (*PublishMessageRequest_InitMessage)(nil), // 61: messaging_pb.PublishMessageRequest.InitMessage + (*PublishFollowMeRequest_InitMessage)(nil), // 62: messaging_pb.PublishFollowMeRequest.InitMessage + (*PublishFollowMeRequest_FlushMessage)(nil), // 63: messaging_pb.PublishFollowMeRequest.FlushMessage + (*PublishFollowMeRequest_CloseMessage)(nil), // 64: messaging_pb.PublishFollowMeRequest.CloseMessage + (*PublishFollowMeRequest_HeartbeatMessage)(nil), // 65: messaging_pb.PublishFollowMeRequest.HeartbeatMessage + (*SubscribeMessageRequest_InitMessage)(nil), // 66: messaging_pb.SubscribeMessageRequest.InitMessage + (*SubscribeMessageRequest_AckMessage)(nil), // 67: messaging_pb.SubscribeMessageRequest.AckMessage + (*SubscribeMessageRequest_SeekMessage)(nil), // 68: messaging_pb.SubscribeMessageRequest.SeekMessage + (*SubscribeMessageResponse_SubscribeCtrlMessage)(nil), // 69: messaging_pb.SubscribeMessageResponse.SubscribeCtrlMessage + (*SubscribeFollowMeRequest_InitMessage)(nil), // 70: messaging_pb.SubscribeFollowMeRequest.InitMessage + (*SubscribeFollowMeRequest_AckMessage)(nil), // 71: messaging_pb.SubscribeFollowMeRequest.AckMessage + (*SubscribeFollowMeRequest_CloseMessage)(nil), // 72: messaging_pb.SubscribeFollowMeRequest.CloseMessage + (*schema_pb.Topic)(nil), // 73: schema_pb.Topic + (*schema_pb.Partition)(nil), // 74: schema_pb.Partition + (*schema_pb.RecordType)(nil), // 75: schema_pb.RecordType + (*filer_pb.LogEntry)(nil), // 76: filer_pb.LogEntry + (*schema_pb.PartitionOffset)(nil), // 77: schema_pb.PartitionOffset + (schema_pb.OffsetType)(0), // 78: schema_pb.OffsetType } var file_mq_broker_proto_depIdxs = []int32{ - 52, // 0: messaging_pb.BrokerStats.stats:type_name -> messaging_pb.BrokerStats.StatsEntry - 70, // 1: messaging_pb.TopicPartitionStats.topic:type_name -> schema_pb.Topic - 71, // 2: messaging_pb.TopicPartitionStats.partition:type_name -> schema_pb.Partition - 53, // 3: messaging_pb.PublisherToPubBalancerRequest.init:type_name -> messaging_pb.PublisherToPubBalancerRequest.InitMessage - 2, // 4: messaging_pb.PublisherToPubBalancerRequest.stats:type_name -> messaging_pb.BrokerStats - 70, // 5: messaging_pb.ConfigureTopicRequest.topic:type_name -> schema_pb.Topic - 8, // 6: messaging_pb.ConfigureTopicRequest.retention:type_name -> messaging_pb.TopicRetention - 72, // 7: messaging_pb.ConfigureTopicRequest.message_record_type:type_name -> schema_pb.RecordType - 17, // 8: messaging_pb.ConfigureTopicResponse.broker_partition_assignments:type_name -> messaging_pb.BrokerPartitionAssignment - 8, // 9: messaging_pb.ConfigureTopicResponse.retention:type_name -> messaging_pb.TopicRetention - 72, // 10: messaging_pb.ConfigureTopicResponse.message_record_type:type_name -> schema_pb.RecordType - 70, // 11: messaging_pb.ListTopicsResponse.topics:type_name -> schema_pb.Topic - 70, // 12: messaging_pb.TopicExistsRequest.topic:type_name -> schema_pb.Topic - 70, // 13: messaging_pb.LookupTopicBrokersRequest.topic:type_name -> schema_pb.Topic - 70, // 14: messaging_pb.LookupTopicBrokersResponse.topic:type_name -> schema_pb.Topic - 17, // 15: messaging_pb.LookupTopicBrokersResponse.broker_partition_assignments:type_name -> messaging_pb.BrokerPartitionAssignment - 71, // 16: messaging_pb.BrokerPartitionAssignment.partition:type_name -> schema_pb.Partition - 70, // 17: messaging_pb.GetTopicConfigurationRequest.topic:type_name -> schema_pb.Topic - 70, // 18: messaging_pb.GetTopicConfigurationResponse.topic:type_name -> schema_pb.Topic - 17, // 19: messaging_pb.GetTopicConfigurationResponse.broker_partition_assignments:type_name -> messaging_pb.BrokerPartitionAssignment - 8, // 20: messaging_pb.GetTopicConfigurationResponse.retention:type_name -> messaging_pb.TopicRetention - 72, // 21: messaging_pb.GetTopicConfigurationResponse.message_record_type:type_name -> schema_pb.RecordType - 70, // 22: messaging_pb.GetTopicPublishersRequest.topic:type_name -> schema_pb.Topic - 24, // 23: messaging_pb.GetTopicPublishersResponse.publishers:type_name -> messaging_pb.TopicPublisher - 70, // 24: messaging_pb.GetTopicSubscribersRequest.topic:type_name -> schema_pb.Topic - 25, // 25: messaging_pb.GetTopicSubscribersResponse.subscribers:type_name -> messaging_pb.TopicSubscriber - 71, // 26: messaging_pb.TopicPublisher.partition:type_name -> schema_pb.Partition - 71, // 27: messaging_pb.TopicSubscriber.partition:type_name -> schema_pb.Partition - 70, // 28: messaging_pb.AssignTopicPartitionsRequest.topic:type_name -> schema_pb.Topic - 17, // 29: messaging_pb.AssignTopicPartitionsRequest.broker_partition_assignments:type_name -> messaging_pb.BrokerPartitionAssignment - 54, // 30: messaging_pb.SubscriberToSubCoordinatorRequest.init:type_name -> messaging_pb.SubscriberToSubCoordinatorRequest.InitMessage - 56, // 31: messaging_pb.SubscriberToSubCoordinatorRequest.ack_assignment:type_name -> messaging_pb.SubscriberToSubCoordinatorRequest.AckAssignmentMessage - 55, // 32: messaging_pb.SubscriberToSubCoordinatorRequest.ack_un_assignment:type_name -> messaging_pb.SubscriberToSubCoordinatorRequest.AckUnAssignmentMessage - 57, // 33: messaging_pb.SubscriberToSubCoordinatorResponse.assignment:type_name -> messaging_pb.SubscriberToSubCoordinatorResponse.Assignment - 58, // 34: messaging_pb.SubscriberToSubCoordinatorResponse.un_assignment:type_name -> messaging_pb.SubscriberToSubCoordinatorResponse.UnAssignment - 30, // 35: messaging_pb.DataMessage.ctrl:type_name -> messaging_pb.ControlMessage - 59, // 36: messaging_pb.PublishMessageRequest.init:type_name -> messaging_pb.PublishMessageRequest.InitMessage - 31, // 37: messaging_pb.PublishMessageRequest.data:type_name -> messaging_pb.DataMessage - 60, // 38: messaging_pb.PublishFollowMeRequest.init:type_name -> messaging_pb.PublishFollowMeRequest.InitMessage - 31, // 39: messaging_pb.PublishFollowMeRequest.data:type_name -> messaging_pb.DataMessage - 61, // 40: messaging_pb.PublishFollowMeRequest.flush:type_name -> messaging_pb.PublishFollowMeRequest.FlushMessage - 62, // 41: messaging_pb.PublishFollowMeRequest.close:type_name -> messaging_pb.PublishFollowMeRequest.CloseMessage - 63, // 42: messaging_pb.SubscribeMessageRequest.init:type_name -> messaging_pb.SubscribeMessageRequest.InitMessage - 64, // 43: messaging_pb.SubscribeMessageRequest.ack:type_name -> messaging_pb.SubscribeMessageRequest.AckMessage - 65, // 44: messaging_pb.SubscribeMessageRequest.seek:type_name -> messaging_pb.SubscribeMessageRequest.SeekMessage - 66, // 45: messaging_pb.SubscribeMessageResponse.ctrl:type_name -> messaging_pb.SubscribeMessageResponse.SubscribeCtrlMessage - 31, // 46: messaging_pb.SubscribeMessageResponse.data:type_name -> messaging_pb.DataMessage - 67, // 47: messaging_pb.SubscribeFollowMeRequest.init:type_name -> messaging_pb.SubscribeFollowMeRequest.InitMessage - 68, // 48: messaging_pb.SubscribeFollowMeRequest.ack:type_name -> messaging_pb.SubscribeFollowMeRequest.AckMessage - 69, // 49: messaging_pb.SubscribeFollowMeRequest.close:type_name -> messaging_pb.SubscribeFollowMeRequest.CloseMessage - 70, // 50: messaging_pb.FetchMessageRequest.topic:type_name -> schema_pb.Topic - 71, // 51: messaging_pb.FetchMessageRequest.partition:type_name -> schema_pb.Partition - 31, // 52: messaging_pb.FetchMessageResponse.messages:type_name -> messaging_pb.DataMessage - 70, // 53: messaging_pb.ClosePublishersRequest.topic:type_name -> schema_pb.Topic - 70, // 54: messaging_pb.CloseSubscribersRequest.topic:type_name -> schema_pb.Topic - 70, // 55: messaging_pb.GetUnflushedMessagesRequest.topic:type_name -> schema_pb.Topic - 71, // 56: messaging_pb.GetUnflushedMessagesRequest.partition:type_name -> schema_pb.Partition - 73, // 57: messaging_pb.GetUnflushedMessagesResponse.message:type_name -> filer_pb.LogEntry - 70, // 58: messaging_pb.GetPartitionRangeInfoRequest.topic:type_name -> schema_pb.Topic - 71, // 59: messaging_pb.GetPartitionRangeInfoRequest.partition:type_name -> schema_pb.Partition - 50, // 60: messaging_pb.GetPartitionRangeInfoResponse.offset_range:type_name -> messaging_pb.OffsetRangeInfo - 51, // 61: messaging_pb.GetPartitionRangeInfoResponse.timestamp_range:type_name -> messaging_pb.TimestampRangeInfo - 3, // 62: messaging_pb.BrokerStats.StatsEntry.value:type_name -> messaging_pb.TopicPartitionStats - 70, // 63: messaging_pb.SubscriberToSubCoordinatorRequest.InitMessage.topic:type_name -> schema_pb.Topic - 71, // 64: messaging_pb.SubscriberToSubCoordinatorRequest.AckUnAssignmentMessage.partition:type_name -> schema_pb.Partition - 71, // 65: messaging_pb.SubscriberToSubCoordinatorRequest.AckAssignmentMessage.partition:type_name -> schema_pb.Partition - 17, // 66: messaging_pb.SubscriberToSubCoordinatorResponse.Assignment.partition_assignment:type_name -> messaging_pb.BrokerPartitionAssignment - 71, // 67: messaging_pb.SubscriberToSubCoordinatorResponse.UnAssignment.partition:type_name -> schema_pb.Partition - 70, // 68: messaging_pb.PublishMessageRequest.InitMessage.topic:type_name -> schema_pb.Topic - 71, // 69: messaging_pb.PublishMessageRequest.InitMessage.partition:type_name -> schema_pb.Partition - 70, // 70: messaging_pb.PublishFollowMeRequest.InitMessage.topic:type_name -> schema_pb.Topic - 71, // 71: messaging_pb.PublishFollowMeRequest.InitMessage.partition:type_name -> schema_pb.Partition - 70, // 72: messaging_pb.SubscribeMessageRequest.InitMessage.topic:type_name -> schema_pb.Topic - 74, // 73: messaging_pb.SubscribeMessageRequest.InitMessage.partition_offset:type_name -> schema_pb.PartitionOffset - 75, // 74: messaging_pb.SubscribeMessageRequest.InitMessage.offset_type:type_name -> schema_pb.OffsetType - 75, // 75: messaging_pb.SubscribeMessageRequest.SeekMessage.offset_type:type_name -> schema_pb.OffsetType - 70, // 76: messaging_pb.SubscribeFollowMeRequest.InitMessage.topic:type_name -> schema_pb.Topic - 71, // 77: messaging_pb.SubscribeFollowMeRequest.InitMessage.partition:type_name -> schema_pb.Partition - 0, // 78: messaging_pb.SeaweedMessaging.FindBrokerLeader:input_type -> messaging_pb.FindBrokerLeaderRequest - 4, // 79: messaging_pb.SeaweedMessaging.PublisherToPubBalancer:input_type -> messaging_pb.PublisherToPubBalancerRequest - 6, // 80: messaging_pb.SeaweedMessaging.BalanceTopics:input_type -> messaging_pb.BalanceTopicsRequest - 11, // 81: messaging_pb.SeaweedMessaging.ListTopics:input_type -> messaging_pb.ListTopicsRequest - 13, // 82: messaging_pb.SeaweedMessaging.TopicExists:input_type -> messaging_pb.TopicExistsRequest - 9, // 83: messaging_pb.SeaweedMessaging.ConfigureTopic:input_type -> messaging_pb.ConfigureTopicRequest - 15, // 84: messaging_pb.SeaweedMessaging.LookupTopicBrokers:input_type -> messaging_pb.LookupTopicBrokersRequest - 18, // 85: messaging_pb.SeaweedMessaging.GetTopicConfiguration:input_type -> messaging_pb.GetTopicConfigurationRequest - 20, // 86: messaging_pb.SeaweedMessaging.GetTopicPublishers:input_type -> messaging_pb.GetTopicPublishersRequest - 22, // 87: messaging_pb.SeaweedMessaging.GetTopicSubscribers:input_type -> messaging_pb.GetTopicSubscribersRequest - 26, // 88: messaging_pb.SeaweedMessaging.AssignTopicPartitions:input_type -> messaging_pb.AssignTopicPartitionsRequest - 42, // 89: messaging_pb.SeaweedMessaging.ClosePublishers:input_type -> messaging_pb.ClosePublishersRequest - 44, // 90: messaging_pb.SeaweedMessaging.CloseSubscribers:input_type -> messaging_pb.CloseSubscribersRequest - 28, // 91: messaging_pb.SeaweedMessaging.SubscriberToSubCoordinator:input_type -> messaging_pb.SubscriberToSubCoordinatorRequest - 32, // 92: messaging_pb.SeaweedMessaging.PublishMessage:input_type -> messaging_pb.PublishMessageRequest - 36, // 93: messaging_pb.SeaweedMessaging.SubscribeMessage:input_type -> messaging_pb.SubscribeMessageRequest - 34, // 94: messaging_pb.SeaweedMessaging.PublishFollowMe:input_type -> messaging_pb.PublishFollowMeRequest - 38, // 95: messaging_pb.SeaweedMessaging.SubscribeFollowMe:input_type -> messaging_pb.SubscribeFollowMeRequest - 40, // 96: messaging_pb.SeaweedMessaging.FetchMessage:input_type -> messaging_pb.FetchMessageRequest - 46, // 97: messaging_pb.SeaweedMessaging.GetUnflushedMessages:input_type -> messaging_pb.GetUnflushedMessagesRequest - 48, // 98: messaging_pb.SeaweedMessaging.GetPartitionRangeInfo:input_type -> messaging_pb.GetPartitionRangeInfoRequest - 1, // 99: messaging_pb.SeaweedMessaging.FindBrokerLeader:output_type -> messaging_pb.FindBrokerLeaderResponse - 5, // 100: messaging_pb.SeaweedMessaging.PublisherToPubBalancer:output_type -> messaging_pb.PublisherToPubBalancerResponse - 7, // 101: messaging_pb.SeaweedMessaging.BalanceTopics:output_type -> messaging_pb.BalanceTopicsResponse - 12, // 102: messaging_pb.SeaweedMessaging.ListTopics:output_type -> messaging_pb.ListTopicsResponse - 14, // 103: messaging_pb.SeaweedMessaging.TopicExists:output_type -> messaging_pb.TopicExistsResponse - 10, // 104: messaging_pb.SeaweedMessaging.ConfigureTopic:output_type -> messaging_pb.ConfigureTopicResponse - 16, // 105: messaging_pb.SeaweedMessaging.LookupTopicBrokers:output_type -> messaging_pb.LookupTopicBrokersResponse - 19, // 106: messaging_pb.SeaweedMessaging.GetTopicConfiguration:output_type -> messaging_pb.GetTopicConfigurationResponse - 21, // 107: messaging_pb.SeaweedMessaging.GetTopicPublishers:output_type -> messaging_pb.GetTopicPublishersResponse - 23, // 108: messaging_pb.SeaweedMessaging.GetTopicSubscribers:output_type -> messaging_pb.GetTopicSubscribersResponse - 27, // 109: messaging_pb.SeaweedMessaging.AssignTopicPartitions:output_type -> messaging_pb.AssignTopicPartitionsResponse - 43, // 110: messaging_pb.SeaweedMessaging.ClosePublishers:output_type -> messaging_pb.ClosePublishersResponse - 45, // 111: messaging_pb.SeaweedMessaging.CloseSubscribers:output_type -> messaging_pb.CloseSubscribersResponse - 29, // 112: messaging_pb.SeaweedMessaging.SubscriberToSubCoordinator:output_type -> messaging_pb.SubscriberToSubCoordinatorResponse - 33, // 113: messaging_pb.SeaweedMessaging.PublishMessage:output_type -> messaging_pb.PublishMessageResponse - 37, // 114: messaging_pb.SeaweedMessaging.SubscribeMessage:output_type -> messaging_pb.SubscribeMessageResponse - 35, // 115: messaging_pb.SeaweedMessaging.PublishFollowMe:output_type -> messaging_pb.PublishFollowMeResponse - 39, // 116: messaging_pb.SeaweedMessaging.SubscribeFollowMe:output_type -> messaging_pb.SubscribeFollowMeResponse - 41, // 117: messaging_pb.SeaweedMessaging.FetchMessage:output_type -> messaging_pb.FetchMessageResponse - 47, // 118: messaging_pb.SeaweedMessaging.GetUnflushedMessages:output_type -> messaging_pb.GetUnflushedMessagesResponse - 49, // 119: messaging_pb.SeaweedMessaging.GetPartitionRangeInfo:output_type -> messaging_pb.GetPartitionRangeInfoResponse - 99, // [99:120] is the sub-list for method output_type - 78, // [78:99] is the sub-list for method input_type - 78, // [78:78] is the sub-list for extension type_name - 78, // [78:78] is the sub-list for extension extendee - 0, // [0:78] is the sub-list for field type_name + 54, // 0: messaging_pb.BrokerStats.stats:type_name -> messaging_pb.BrokerStats.StatsEntry + 73, // 1: messaging_pb.TopicPartitionStats.topic:type_name -> schema_pb.Topic + 74, // 2: messaging_pb.TopicPartitionStats.partition:type_name -> schema_pb.Partition + 55, // 3: messaging_pb.PublisherToPubBalancerRequest.init:type_name -> messaging_pb.PublisherToPubBalancerRequest.InitMessage + 2, // 4: messaging_pb.PublisherToPubBalancerRequest.stats:type_name -> messaging_pb.BrokerStats + 73, // 5: messaging_pb.ConfigureTopicRequest.topic:type_name -> schema_pb.Topic + 8, // 6: messaging_pb.ConfigureTopicRequest.retention:type_name -> messaging_pb.TopicRetention + 75, // 7: messaging_pb.ConfigureTopicRequest.message_record_type:type_name -> schema_pb.RecordType + 17, // 8: messaging_pb.ConfigureTopicResponse.broker_partition_assignments:type_name -> messaging_pb.BrokerPartitionAssignment + 8, // 9: messaging_pb.ConfigureTopicResponse.retention:type_name -> messaging_pb.TopicRetention + 75, // 10: messaging_pb.ConfigureTopicResponse.message_record_type:type_name -> schema_pb.RecordType + 73, // 11: messaging_pb.ListTopicsResponse.topics:type_name -> schema_pb.Topic + 73, // 12: messaging_pb.TopicExistsRequest.topic:type_name -> schema_pb.Topic + 73, // 13: messaging_pb.LookupTopicBrokersRequest.topic:type_name -> schema_pb.Topic + 73, // 14: messaging_pb.LookupTopicBrokersResponse.topic:type_name -> schema_pb.Topic + 17, // 15: messaging_pb.LookupTopicBrokersResponse.broker_partition_assignments:type_name -> messaging_pb.BrokerPartitionAssignment + 74, // 16: messaging_pb.BrokerPartitionAssignment.partition:type_name -> schema_pb.Partition + 73, // 17: messaging_pb.GetTopicConfigurationRequest.topic:type_name -> schema_pb.Topic + 73, // 18: messaging_pb.GetTopicConfigurationResponse.topic:type_name -> schema_pb.Topic + 17, // 19: messaging_pb.GetTopicConfigurationResponse.broker_partition_assignments:type_name -> messaging_pb.BrokerPartitionAssignment + 8, // 20: messaging_pb.GetTopicConfigurationResponse.retention:type_name -> messaging_pb.TopicRetention + 75, // 21: messaging_pb.GetTopicConfigurationResponse.message_record_type:type_name -> schema_pb.RecordType + 73, // 22: messaging_pb.GetTopicPublishersRequest.topic:type_name -> schema_pb.Topic + 24, // 23: messaging_pb.GetTopicPublishersResponse.publishers:type_name -> messaging_pb.TopicPublisher + 73, // 24: messaging_pb.GetTopicSubscribersRequest.topic:type_name -> schema_pb.Topic + 25, // 25: messaging_pb.GetTopicSubscribersResponse.subscribers:type_name -> messaging_pb.TopicSubscriber + 74, // 26: messaging_pb.TopicPublisher.partition:type_name -> schema_pb.Partition + 74, // 27: messaging_pb.TopicSubscriber.partition:type_name -> schema_pb.Partition + 73, // 28: messaging_pb.AssignTopicPartitionsRequest.topic:type_name -> schema_pb.Topic + 17, // 29: messaging_pb.AssignTopicPartitionsRequest.broker_partition_assignments:type_name -> messaging_pb.BrokerPartitionAssignment + 56, // 30: messaging_pb.SubscriberToSubCoordinatorRequest.init:type_name -> messaging_pb.SubscriberToSubCoordinatorRequest.InitMessage + 58, // 31: messaging_pb.SubscriberToSubCoordinatorRequest.ack_assignment:type_name -> messaging_pb.SubscriberToSubCoordinatorRequest.AckAssignmentMessage + 57, // 32: messaging_pb.SubscriberToSubCoordinatorRequest.ack_un_assignment:type_name -> messaging_pb.SubscriberToSubCoordinatorRequest.AckUnAssignmentMessage + 59, // 33: messaging_pb.SubscriberToSubCoordinatorResponse.assignment:type_name -> messaging_pb.SubscriberToSubCoordinatorResponse.Assignment + 60, // 34: messaging_pb.SubscriberToSubCoordinatorResponse.un_assignment:type_name -> messaging_pb.SubscriberToSubCoordinatorResponse.UnAssignment + 30, // 35: messaging_pb.DataMessage.ctrl:type_name -> messaging_pb.ControlMessage + 61, // 36: messaging_pb.PublishMessageRequest.init:type_name -> messaging_pb.PublishMessageRequest.InitMessage + 31, // 37: messaging_pb.PublishMessageRequest.data:type_name -> messaging_pb.DataMessage + 62, // 38: messaging_pb.PublishFollowMeRequest.init:type_name -> messaging_pb.PublishFollowMeRequest.InitMessage + 31, // 39: messaging_pb.PublishFollowMeRequest.data:type_name -> messaging_pb.DataMessage + 63, // 40: messaging_pb.PublishFollowMeRequest.flush:type_name -> messaging_pb.PublishFollowMeRequest.FlushMessage + 64, // 41: messaging_pb.PublishFollowMeRequest.close:type_name -> messaging_pb.PublishFollowMeRequest.CloseMessage + 76, // 42: messaging_pb.PublishFollowMeRequest.entry:type_name -> filer_pb.LogEntry + 65, // 43: messaging_pb.PublishFollowMeRequest.heartbeat:type_name -> messaging_pb.PublishFollowMeRequest.HeartbeatMessage + 73, // 44: messaging_pb.EndPartitionGenerationRequest.topic:type_name -> schema_pb.Topic + 74, // 45: messaging_pb.EndPartitionGenerationRequest.partition:type_name -> schema_pb.Partition + 66, // 46: messaging_pb.SubscribeMessageRequest.init:type_name -> messaging_pb.SubscribeMessageRequest.InitMessage + 67, // 47: messaging_pb.SubscribeMessageRequest.ack:type_name -> messaging_pb.SubscribeMessageRequest.AckMessage + 68, // 48: messaging_pb.SubscribeMessageRequest.seek:type_name -> messaging_pb.SubscribeMessageRequest.SeekMessage + 69, // 49: messaging_pb.SubscribeMessageResponse.ctrl:type_name -> messaging_pb.SubscribeMessageResponse.SubscribeCtrlMessage + 31, // 50: messaging_pb.SubscribeMessageResponse.data:type_name -> messaging_pb.DataMessage + 70, // 51: messaging_pb.SubscribeFollowMeRequest.init:type_name -> messaging_pb.SubscribeFollowMeRequest.InitMessage + 71, // 52: messaging_pb.SubscribeFollowMeRequest.ack:type_name -> messaging_pb.SubscribeFollowMeRequest.AckMessage + 72, // 53: messaging_pb.SubscribeFollowMeRequest.close:type_name -> messaging_pb.SubscribeFollowMeRequest.CloseMessage + 73, // 54: messaging_pb.FetchMessageRequest.topic:type_name -> schema_pb.Topic + 74, // 55: messaging_pb.FetchMessageRequest.partition:type_name -> schema_pb.Partition + 31, // 56: messaging_pb.FetchMessageResponse.messages:type_name -> messaging_pb.DataMessage + 73, // 57: messaging_pb.ClosePublishersRequest.topic:type_name -> schema_pb.Topic + 73, // 58: messaging_pb.CloseSubscribersRequest.topic:type_name -> schema_pb.Topic + 73, // 59: messaging_pb.GetUnflushedMessagesRequest.topic:type_name -> schema_pb.Topic + 74, // 60: messaging_pb.GetUnflushedMessagesRequest.partition:type_name -> schema_pb.Partition + 76, // 61: messaging_pb.GetUnflushedMessagesResponse.message:type_name -> filer_pb.LogEntry + 73, // 62: messaging_pb.GetPartitionRangeInfoRequest.topic:type_name -> schema_pb.Topic + 74, // 63: messaging_pb.GetPartitionRangeInfoRequest.partition:type_name -> schema_pb.Partition + 52, // 64: messaging_pb.GetPartitionRangeInfoResponse.offset_range:type_name -> messaging_pb.OffsetRangeInfo + 53, // 65: messaging_pb.GetPartitionRangeInfoResponse.timestamp_range:type_name -> messaging_pb.TimestampRangeInfo + 3, // 66: messaging_pb.BrokerStats.StatsEntry.value:type_name -> messaging_pb.TopicPartitionStats + 73, // 67: messaging_pb.SubscriberToSubCoordinatorRequest.InitMessage.topic:type_name -> schema_pb.Topic + 74, // 68: messaging_pb.SubscriberToSubCoordinatorRequest.AckUnAssignmentMessage.partition:type_name -> schema_pb.Partition + 74, // 69: messaging_pb.SubscriberToSubCoordinatorRequest.AckAssignmentMessage.partition:type_name -> schema_pb.Partition + 17, // 70: messaging_pb.SubscriberToSubCoordinatorResponse.Assignment.partition_assignment:type_name -> messaging_pb.BrokerPartitionAssignment + 74, // 71: messaging_pb.SubscriberToSubCoordinatorResponse.UnAssignment.partition:type_name -> schema_pb.Partition + 73, // 72: messaging_pb.PublishMessageRequest.InitMessage.topic:type_name -> schema_pb.Topic + 74, // 73: messaging_pb.PublishMessageRequest.InitMessage.partition:type_name -> schema_pb.Partition + 73, // 74: messaging_pb.PublishFollowMeRequest.InitMessage.topic:type_name -> schema_pb.Topic + 74, // 75: messaging_pb.PublishFollowMeRequest.InitMessage.partition:type_name -> schema_pb.Partition + 73, // 76: messaging_pb.SubscribeMessageRequest.InitMessage.topic:type_name -> schema_pb.Topic + 77, // 77: messaging_pb.SubscribeMessageRequest.InitMessage.partition_offset:type_name -> schema_pb.PartitionOffset + 78, // 78: messaging_pb.SubscribeMessageRequest.InitMessage.offset_type:type_name -> schema_pb.OffsetType + 78, // 79: messaging_pb.SubscribeMessageRequest.SeekMessage.offset_type:type_name -> schema_pb.OffsetType + 73, // 80: messaging_pb.SubscribeFollowMeRequest.InitMessage.topic:type_name -> schema_pb.Topic + 74, // 81: messaging_pb.SubscribeFollowMeRequest.InitMessage.partition:type_name -> schema_pb.Partition + 0, // 82: messaging_pb.SeaweedMessaging.FindBrokerLeader:input_type -> messaging_pb.FindBrokerLeaderRequest + 4, // 83: messaging_pb.SeaweedMessaging.PublisherToPubBalancer:input_type -> messaging_pb.PublisherToPubBalancerRequest + 6, // 84: messaging_pb.SeaweedMessaging.BalanceTopics:input_type -> messaging_pb.BalanceTopicsRequest + 11, // 85: messaging_pb.SeaweedMessaging.ListTopics:input_type -> messaging_pb.ListTopicsRequest + 13, // 86: messaging_pb.SeaweedMessaging.TopicExists:input_type -> messaging_pb.TopicExistsRequest + 9, // 87: messaging_pb.SeaweedMessaging.ConfigureTopic:input_type -> messaging_pb.ConfigureTopicRequest + 15, // 88: messaging_pb.SeaweedMessaging.LookupTopicBrokers:input_type -> messaging_pb.LookupTopicBrokersRequest + 18, // 89: messaging_pb.SeaweedMessaging.GetTopicConfiguration:input_type -> messaging_pb.GetTopicConfigurationRequest + 20, // 90: messaging_pb.SeaweedMessaging.GetTopicPublishers:input_type -> messaging_pb.GetTopicPublishersRequest + 22, // 91: messaging_pb.SeaweedMessaging.GetTopicSubscribers:input_type -> messaging_pb.GetTopicSubscribersRequest + 26, // 92: messaging_pb.SeaweedMessaging.AssignTopicPartitions:input_type -> messaging_pb.AssignTopicPartitionsRequest + 44, // 93: messaging_pb.SeaweedMessaging.ClosePublishers:input_type -> messaging_pb.ClosePublishersRequest + 46, // 94: messaging_pb.SeaweedMessaging.CloseSubscribers:input_type -> messaging_pb.CloseSubscribersRequest + 28, // 95: messaging_pb.SeaweedMessaging.SubscriberToSubCoordinator:input_type -> messaging_pb.SubscriberToSubCoordinatorRequest + 32, // 96: messaging_pb.SeaweedMessaging.PublishMessage:input_type -> messaging_pb.PublishMessageRequest + 38, // 97: messaging_pb.SeaweedMessaging.SubscribeMessage:input_type -> messaging_pb.SubscribeMessageRequest + 34, // 98: messaging_pb.SeaweedMessaging.PublishFollowMe:input_type -> messaging_pb.PublishFollowMeRequest + 40, // 99: messaging_pb.SeaweedMessaging.SubscribeFollowMe:input_type -> messaging_pb.SubscribeFollowMeRequest + 36, // 100: messaging_pb.SeaweedMessaging.EndPartitionGeneration:input_type -> messaging_pb.EndPartitionGenerationRequest + 42, // 101: messaging_pb.SeaweedMessaging.FetchMessage:input_type -> messaging_pb.FetchMessageRequest + 48, // 102: messaging_pb.SeaweedMessaging.GetUnflushedMessages:input_type -> messaging_pb.GetUnflushedMessagesRequest + 50, // 103: messaging_pb.SeaweedMessaging.GetPartitionRangeInfo:input_type -> messaging_pb.GetPartitionRangeInfoRequest + 1, // 104: messaging_pb.SeaweedMessaging.FindBrokerLeader:output_type -> messaging_pb.FindBrokerLeaderResponse + 5, // 105: messaging_pb.SeaweedMessaging.PublisherToPubBalancer:output_type -> messaging_pb.PublisherToPubBalancerResponse + 7, // 106: messaging_pb.SeaweedMessaging.BalanceTopics:output_type -> messaging_pb.BalanceTopicsResponse + 12, // 107: messaging_pb.SeaweedMessaging.ListTopics:output_type -> messaging_pb.ListTopicsResponse + 14, // 108: messaging_pb.SeaweedMessaging.TopicExists:output_type -> messaging_pb.TopicExistsResponse + 10, // 109: messaging_pb.SeaweedMessaging.ConfigureTopic:output_type -> messaging_pb.ConfigureTopicResponse + 16, // 110: messaging_pb.SeaweedMessaging.LookupTopicBrokers:output_type -> messaging_pb.LookupTopicBrokersResponse + 19, // 111: messaging_pb.SeaweedMessaging.GetTopicConfiguration:output_type -> messaging_pb.GetTopicConfigurationResponse + 21, // 112: messaging_pb.SeaweedMessaging.GetTopicPublishers:output_type -> messaging_pb.GetTopicPublishersResponse + 23, // 113: messaging_pb.SeaweedMessaging.GetTopicSubscribers:output_type -> messaging_pb.GetTopicSubscribersResponse + 27, // 114: messaging_pb.SeaweedMessaging.AssignTopicPartitions:output_type -> messaging_pb.AssignTopicPartitionsResponse + 45, // 115: messaging_pb.SeaweedMessaging.ClosePublishers:output_type -> messaging_pb.ClosePublishersResponse + 47, // 116: messaging_pb.SeaweedMessaging.CloseSubscribers:output_type -> messaging_pb.CloseSubscribersResponse + 29, // 117: messaging_pb.SeaweedMessaging.SubscriberToSubCoordinator:output_type -> messaging_pb.SubscriberToSubCoordinatorResponse + 33, // 118: messaging_pb.SeaweedMessaging.PublishMessage:output_type -> messaging_pb.PublishMessageResponse + 39, // 119: messaging_pb.SeaweedMessaging.SubscribeMessage:output_type -> messaging_pb.SubscribeMessageResponse + 35, // 120: messaging_pb.SeaweedMessaging.PublishFollowMe:output_type -> messaging_pb.PublishFollowMeResponse + 41, // 121: messaging_pb.SeaweedMessaging.SubscribeFollowMe:output_type -> messaging_pb.SubscribeFollowMeResponse + 37, // 122: messaging_pb.SeaweedMessaging.EndPartitionGeneration:output_type -> messaging_pb.EndPartitionGenerationResponse + 43, // 123: messaging_pb.SeaweedMessaging.FetchMessage:output_type -> messaging_pb.FetchMessageResponse + 49, // 124: messaging_pb.SeaweedMessaging.GetUnflushedMessages:output_type -> messaging_pb.GetUnflushedMessagesResponse + 51, // 125: messaging_pb.SeaweedMessaging.GetPartitionRangeInfo:output_type -> messaging_pb.GetPartitionRangeInfoResponse + 104, // [104:126] is the sub-list for method output_type + 82, // [82:104] is the sub-list for method input_type + 82, // [82:82] is the sub-list for extension type_name + 82, // [82:82] is the sub-list for extension extendee + 0, // [0:82] is the sub-list for field type_name } func init() { file_mq_broker_proto_init() } @@ -4812,17 +5040,19 @@ func file_mq_broker_proto_init() { (*PublishFollowMeRequest_Data)(nil), (*PublishFollowMeRequest_Flush)(nil), (*PublishFollowMeRequest_Close)(nil), + (*PublishFollowMeRequest_Entry)(nil), + (*PublishFollowMeRequest_Heartbeat)(nil), } - file_mq_broker_proto_msgTypes[36].OneofWrappers = []any{ + file_mq_broker_proto_msgTypes[38].OneofWrappers = []any{ (*SubscribeMessageRequest_Init)(nil), (*SubscribeMessageRequest_Ack)(nil), (*SubscribeMessageRequest_Seek)(nil), } - file_mq_broker_proto_msgTypes[37].OneofWrappers = []any{ + file_mq_broker_proto_msgTypes[39].OneofWrappers = []any{ (*SubscribeMessageResponse_Ctrl)(nil), (*SubscribeMessageResponse_Data)(nil), } - file_mq_broker_proto_msgTypes[38].OneofWrappers = []any{ + file_mq_broker_proto_msgTypes[40].OneofWrappers = []any{ (*SubscribeFollowMeRequest_Init)(nil), (*SubscribeFollowMeRequest_Ack)(nil), (*SubscribeFollowMeRequest_Close)(nil), @@ -4833,7 +5063,7 @@ func file_mq_broker_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_mq_broker_proto_rawDesc), len(file_mq_broker_proto_rawDesc)), NumEnums: 0, - NumMessages: 70, + NumMessages: 73, NumExtensions: 0, NumServices: 1, }, diff --git a/weed/pb/mq_pb/mq_broker_grpc.pb.go b/weed/pb/mq_pb/mq_broker_grpc.pb.go index 0634133084..03ca0bee1e 100644 --- a/weed/pb/mq_pb/mq_broker_grpc.pb.go +++ b/weed/pb/mq_pb/mq_broker_grpc.pb.go @@ -37,6 +37,7 @@ const ( SeaweedMessaging_SubscribeMessage_FullMethodName = "/messaging_pb.SeaweedMessaging/SubscribeMessage" SeaweedMessaging_PublishFollowMe_FullMethodName = "/messaging_pb.SeaweedMessaging/PublishFollowMe" SeaweedMessaging_SubscribeFollowMe_FullMethodName = "/messaging_pb.SeaweedMessaging/SubscribeFollowMe" + SeaweedMessaging_EndPartitionGeneration_FullMethodName = "/messaging_pb.SeaweedMessaging/EndPartitionGeneration" SeaweedMessaging_FetchMessage_FullMethodName = "/messaging_pb.SeaweedMessaging/FetchMessage" SeaweedMessaging_GetUnflushedMessages_FullMethodName = "/messaging_pb.SeaweedMessaging/GetUnflushedMessages" SeaweedMessaging_GetPartitionRangeInfo_FullMethodName = "/messaging_pb.SeaweedMessaging/GetPartitionRangeInfo" @@ -71,6 +72,8 @@ type SeaweedMessagingClient interface { // The lead broker asks a follower broker to follow itself PublishFollowMe(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PublishFollowMeRequest, PublishFollowMeResponse], error) SubscribeFollowMe(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[SubscribeFollowMeRequest, SubscribeFollowMeResponse], error) + // A broker of a partition's pair reports that the pair broke; the balancer assigns a new pair + EndPartitionGeneration(ctx context.Context, in *EndPartitionGenerationRequest, opts ...grpc.CallOption) (*EndPartitionGenerationResponse, error) // Stateless fetch API (Kafka-style) - request/response pattern // This is the recommended API for Kafka gateway and other stateless clients // No streaming, no session state - each request is completely independent @@ -287,6 +290,16 @@ func (c *seaweedMessagingClient) SubscribeFollowMe(ctx context.Context, opts ... // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type SeaweedMessaging_SubscribeFollowMeClient = grpc.ClientStreamingClient[SubscribeFollowMeRequest, SubscribeFollowMeResponse] +func (c *seaweedMessagingClient) EndPartitionGeneration(ctx context.Context, in *EndPartitionGenerationRequest, opts ...grpc.CallOption) (*EndPartitionGenerationResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(EndPartitionGenerationResponse) + err := c.cc.Invoke(ctx, SeaweedMessaging_EndPartitionGeneration_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *seaweedMessagingClient) FetchMessage(ctx context.Context, in *FetchMessageRequest, opts ...grpc.CallOption) (*FetchMessageResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(FetchMessageResponse) @@ -355,6 +368,8 @@ type SeaweedMessagingServer interface { // The lead broker asks a follower broker to follow itself PublishFollowMe(grpc.BidiStreamingServer[PublishFollowMeRequest, PublishFollowMeResponse]) error SubscribeFollowMe(grpc.ClientStreamingServer[SubscribeFollowMeRequest, SubscribeFollowMeResponse]) error + // A broker of a partition's pair reports that the pair broke; the balancer assigns a new pair + EndPartitionGeneration(context.Context, *EndPartitionGenerationRequest) (*EndPartitionGenerationResponse, error) // Stateless fetch API (Kafka-style) - request/response pattern // This is the recommended API for Kafka gateway and other stateless clients // No streaming, no session state - each request is completely independent @@ -427,6 +442,9 @@ func (UnimplementedSeaweedMessagingServer) PublishFollowMe(grpc.BidiStreamingSer func (UnimplementedSeaweedMessagingServer) SubscribeFollowMe(grpc.ClientStreamingServer[SubscribeFollowMeRequest, SubscribeFollowMeResponse]) error { return status.Errorf(codes.Unimplemented, "method SubscribeFollowMe not implemented") } +func (UnimplementedSeaweedMessagingServer) EndPartitionGeneration(context.Context, *EndPartitionGenerationRequest) (*EndPartitionGenerationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EndPartitionGeneration not implemented") +} func (UnimplementedSeaweedMessagingServer) FetchMessage(context.Context, *FetchMessageRequest) (*FetchMessageResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method FetchMessage not implemented") } @@ -447,7 +465,7 @@ type UnsafeSeaweedMessagingServer interface { } func RegisterSeaweedMessagingServer(s grpc.ServiceRegistrar, srv SeaweedMessagingServer) { - // If the following call pancis, it indicates UnimplementedSeaweedMessagingServer was + // If the following call panics, it indicates UnimplementedSeaweedMessagingServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. @@ -715,6 +733,24 @@ func _SeaweedMessaging_SubscribeFollowMe_Handler(srv interface{}, stream grpc.Se // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type SeaweedMessaging_SubscribeFollowMeServer = grpc.ClientStreamingServer[SubscribeFollowMeRequest, SubscribeFollowMeResponse] +func _SeaweedMessaging_EndPartitionGeneration_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(EndPartitionGenerationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SeaweedMessagingServer).EndPartitionGeneration(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SeaweedMessaging_EndPartitionGeneration_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SeaweedMessagingServer).EndPartitionGeneration(ctx, req.(*EndPartitionGenerationRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _SeaweedMessaging_FetchMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(FetchMessageRequest) if err := dec(in); err != nil { @@ -817,6 +853,10 @@ var SeaweedMessaging_ServiceDesc = grpc.ServiceDesc{ MethodName: "CloseSubscribers", Handler: _SeaweedMessaging_CloseSubscribers_Handler, }, + { + MethodName: "EndPartitionGeneration", + Handler: _SeaweedMessaging_EndPartitionGeneration_Handler, + }, { MethodName: "FetchMessage", Handler: _SeaweedMessaging_FetchMessage_Handler, diff --git a/weed/util/log_buffer/log_buffer.go b/weed/util/log_buffer/log_buffer.go index 9599d6e209..0ebeee8073 100644 --- a/weed/util/log_buffer/log_buffer.go +++ b/weed/util/log_buffer/log_buffer.go @@ -793,6 +793,11 @@ func (logBuffer *LogBuffer) NoteFlushDropped(n int) { logBuffer.flushDroppedBytes.Add(int64(n)) } +// GetLastFlushedOffset returns the highest offset a landed flush stored, or -1. +func (logBuffer *LogBuffer) GetLastFlushedOffset() int64 { + return logBuffer.lastFlushedOffset.Load() +} + // IsAllFlushed returns true if all data in the buffer has been flushed, after calling ShutdownLogBuffer(). func (logBuffer *LogBuffer) IsAllFlushed() bool { return logBuffer.isAllFlushed