Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock test for 548 #555

Merged
merged 1 commit into from
May 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/issues/548_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package issues

import (
"context"
"testing"
"time"

"github.com/ClickHouse/clickhouse-go/v2"
"github.com/stretchr/testify/assert"
)

func Test548(t *testing.T) {
var (
ctx, cancel = context.WithTimeout(context.Background(), time.Second)
conn, err = clickhouse.Open(&clickhouse.Options{
Addr: []string{"127.0.0.1:9000"},
Auth: clickhouse.Auth{
Database: "default",
Username: "default",
Password: "",
},
DialTimeout: time.Second,
Compression: &clickhouse.Compression{
Method: clickhouse.CompressionLZ4,
},
//Debug: true,
})
)
defer cancel()
assert.NoError(t, err)
// give it plenty of time before we conclusively assume deadlock
timeout := time.After(5 * time.Second)
done := make(chan bool)
go func() {
// should take 1s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no correct, should take approx 1s if no deadlock

rows, _ := conn.Query(ctx, "SELECT sleepEachRow(0.001) as Col1 FROM system.numbers LIMIT 1000 SETTINGS max_block_size=10;")
rows.Close()
done <- true
}()

select {
case <-timeout:
t.Fatal("Close() deadlocked")
case <-done:
}
}