Skip to content

Create tso stream without timeout may block for a while #2642

@rleungx

Description

@rleungx

In client/client.go, when tsLoop starts, it will first initialize the tso stream as following:

for {
	var err error
	
	if stream == nil {
		var ctx context.Context
		ctx, cancel = context.WithCancel(loopCtx)
		stream, err = c.leaderClient().Tso(ctx)
		if err != nil {
			select {
			case <-loopCtx.Done():
				cancel()
				return
			default:
			}
			log.Error("[pd] create tso stream error", zap.Error(err))
			c.ScheduleCheckLeader()
			cancel()
			c.revokeTSORequest(errors.WithStack(err))
			select {
			case <-time.After(time.Second):
			case <-loopCtx.Done():
				return
			}
			continue
		}
	}
        ...
}

But if at that time the server crash, it will block until TCP layer timeout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    do-not-merge/work-in-progressIndicates that a PR should not merge because it is a work in progress.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions