Skip to content

PingContext not cancel when ctx deadline #1005

Closed
@zjmnssy

Description

@zjmnssy

Issue description

when i specially use a unavailable mysql server address to test PingContext, PingContext not cancel when ctx deadline, and every time it will cost 21 seconds when return error of " dial tcp 192.168.31.123:3306: connect: connection refused", but it should return error of "context canceled" after my ctx timeout.

Example code

ctx, cancel := context.WithTimeout(context.Background(), time.Duration(3)*time.Second)
defer cancel()

err = db.PingContext(ctx)
if err != nil {
    return
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions