Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

fix: create table after cluster state stable #187

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions server/service/grpc/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,24 @@ func (s *Service) CreateTable(ctx context.Context, req *metaservicepb.CreateTabl
return nil
}

p, err := c.GetProcedureFactory().MakeCreateTableProcedure(ctx, coordinator.CreateTableRequest{
ClusterMetadata: c.GetMetadata(),
SourceReq: req,
OnSucceeded: onSucceeded,
OnFailed: onFailed,
})
if err != nil {
log.Error("fail to create table, factory create procedure", zap.Error(err))
return &metaservicepb.CreateTableResponse{Header: responseHeader(err, "create table")}, nil
}
topology := c.GetMetadata().GetClusterSnapshot().Topology
if topology.IsStable() {
p, err := c.GetProcedureFactory().MakeCreateTableProcedure(ctx, coordinator.CreateTableRequest{
ClusterMetadata: c.GetMetadata(),
SourceReq: req,
OnSucceeded: onSucceeded,
OnFailed: onFailed,
})
if err != nil {
log.Error("fail to create table, factory create procedure", zap.Error(err))
return &metaservicepb.CreateTableResponse{Header: responseHeader(err, "create table")}, nil
}

err = c.GetProcedureManager().Submit(ctx, p)
if err != nil {
log.Error("fail to create table, manager submit procedure", zap.Error(err))
return &metaservicepb.CreateTableResponse{Header: responseHeader(err, "create table")}, nil
err = c.GetProcedureManager().Submit(ctx, p)
if err != nil {
log.Error("fail to create table, manager submit procedure", zap.Error(err))
return &metaservicepb.CreateTableResponse{Header: responseHeader(err, "create table")}, nil
}
}

select {
Expand Down