Skip to content

Setting wait_timeout to 0 doesn't take effect #23351

Closed
@djshow832

Description

Bug Report

After setting wait_timeout to a non-zero value and then setting it back to 0, the connection will still timeout.

func (p *packetIO) readOnePacket() ([]byte, error) {
	var header [4]byte
	if p.readTimeout > 0 {
		if err := p.bufReadConn.SetReadDeadline(time.Now().Add(p.readTimeout)); err != nil {
			return nil, err
		}
	}
...

In this function, setting wait_timeout to 0 won't go into SetReadDeadline, so it doesn't take effect.

1. Minimal reproduce step (Required)

            Statement stmt = conn.createStatement();
            stmt.execute("set @@wait_timeout=1");
            stmt.execute("set @@wait_timeout=0");
            Thread.sleep(3000);
            ResultSet rs = stmt.executeQuery("select 1");

2. What did you expect to see? (Required)

The query is executed successfully.

3. What did you see instead (Required)

It reports CommunicationsException.

4. What is your TiDB version? (Required)

v3.0.17

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

component/serverhelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.severity/moderatesig/sql-infraSIG: SQL Infratype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions