fix(bssdk): add print log, wait shard node return no leader

default shard node retry time

with: #22918200

Signed-off-by: mawei029 <mawei2@oppo.com>
This commit is contained in:
mawei029 2024-12-30 10:31:02 +08:00 committed by slasher
parent ecd4101463
commit b1c8321beb
2 changed files with 6 additions and 1 deletions

View File

@ -293,6 +293,8 @@ func NewStreamHandler(cfg *StreamConfig, stopCh <-chan struct{}) (h StreamHandle
StreamConfig: *cfg,
}
if cfg.ShardnodeConfig != nil { // enable shard node
// Do not use rpc retry, because the stream blob handles retries itself
defaulter.LessOrEqual(&cfg.ShardnodeConfig.Config.Retry, int(1))
handler.shardnodeClient = shardnode.New(cfg.ShardnodeConfig.Config)
}

View File

@ -586,6 +586,8 @@ func (h *Handler) waitShardnodeNextLeader(ctx context.Context, clusterID proto.C
}
func (h *Handler) getLeaderShardInfo(ctx context.Context, clusterID proto.ClusterID, host string, diskID proto.DiskID, suid proto.Suid, badDisk proto.DiskID) (shardnode.ShardStats, error) {
span := trace.SpanFromContextSafe(ctx)
for i := 0; i < h.ShardnodeRetryTimes; i++ {
// 1. get leader info
leader, err := h.shardnodeClient.GetShardStats(ctx, host, shardnode.GetShardArgs{
@ -598,6 +600,7 @@ func (h *Handler) getLeaderShardInfo(ctx context.Context, clusterID proto.Cluste
// skip bad host. LeaderDiskID means in the election. bad disk is last leader, not start election yet
if leader.LeaderDiskID == 0 || leader.LeaderDiskID == badDisk {
span.Warnf("shard node is in the election, host:%s, disk:%d, suid:%d, badDisk:%d", host, diskID, suid, badDisk)
time.Sleep(time.Millisecond * time.Duration(h.ShardnodeRetryIntervalMS))
continue
}
@ -619,7 +622,7 @@ func (h *Handler) getLeaderShardInfo(ctx context.Context, clusterID proto.Cluste
return ret, nil
}
return shardnode.ShardStats{}, errcode.ErrShardNodeNotLeader
return shardnode.ShardStats{}, errcode.ErrShardNoLeader
}
func (h *Handler) fixCreateBlobArgs(ctx context.Context, args *acapi.CreateBlobArgs) error {