Skip to content

Missing deadline for LeaseGrant when creating session #19778

@qts0312

Description

@qts0312

Bug report criteria

What happened?

In the NewSession function within client/v3/concurrency/session.go, the RPC call LeaseGrant is invoked without a deadline, as shown below.

resp, err := client.Grant(ops.ctx, int64(ops.ttl))

However, LeaseGrant should be called with a deadline set to the ttl value, similar to how the LeaseRevoke RPC is handled with a deadline set to ttl value when closing the session. Otherwise LeaseGrant may stuck and block the NewSession function endlessly.

func (s *Session) Close() error {
	s.Orphan()
	// if revoke takes longer than the ttl, lease is expired anyway
	ctx, cancel := context.WithTimeout(s.opts.ctx, time.Duration(s.opts.ttl)*time.Second)
	_, err := s.client.Revoke(ctx, s.id)
	cancel()
	return err
}

What did you expect to happen?

RPC LeaseGrant can return DeadlineExceeded to avoid endless stuck.

How can we reproduce it (as minimally and precisely as possible)?

When NewSession is called, internal RPC LeaseGrant may stuck and block this function endlessly.

Anything else we need to know?

No response

Etcd version (please run commands below)

$ etcd --version
v3.5.12

$ etcdctl version
# paste output here

Etcd configuration (command line flags or environment variables)

paste your configuration here

Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)

$ etcdctl member list -w table
# paste output here

$ etcdctl --endpoints=<member list> endpoint status -w table
# paste output here

Relevant log output

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions