-
Notifications
You must be signed in to change notification settings - Fork 159
Context not propagated to snowflakeFileTransferAgent on PUT command; cancellation is not supported #1028
Description
Context cancellation works for other queries executed using conn.ExecContext(), but is ignored for PUT/GET commands because it is not propagated any further than the snowflakeConn.processFileTransfer() method.
-
What version of GO driver are you using?
github.com/snowflakedb/gosnowflake v1.7.1 -
What operating system and processor architecture are you using?
macOS 14.1.1 x86_64 -
What version of GO are you using?
go version go1.21.5 darwin/amd64 -
Server version:
8.1.0 -
What did you do?
package main
import (
"context"
"database/sql"
"log"
"time"
"github.com/snowflakedb/gosnowflake"
)
func main() {
cfg := &gosnowflake.Config{
// Redacted
}
dsn, err := gosnowflake.DSN(cfg)
if err != nil {
log.Fatal(err)
}
db, err := sql.Open("snowflake", dsn)
if err != nil {
log.Fatal(err)
}
defer db.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
conn, err := db.Conn(ctx)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
stageName := "my_temp_stage"
createStageQuery := "CREATE OR REPLACE STAGE my_temp_stage" + stageName
putQuery := "PUT file:///path/to/test.parquet @" + stageName + " OVERWRITE=true"
_, err = conn.ExecContext(ctx, createStageQuery)
if err != nil {
log.Fatal(err)
}
go func() {
time.Sleep(10 * time.Second)
log.Println("Canceled")
cancel()
}()
log.Println("Starting PUT upload")
_, err = conn.ExecContext(ctx, putQuery)
if err != nil {
log.Fatal(err)
}
log.Println("Completed PUT upload")
}- What did you expect to see?
Expected Logs
% go run .
2024/01/10 21:11:22 Starting PUT upload
2024/01/10 21:11:32 Canceled
2024/01/10 21:11:32 context canceled
exit status 1
Actual Logs
% go run .
2024/01/10 21:11:22 Starting PUT upload
2024/01/10 21:11:32 Canceled
2024/01/10 21:12:36 Completed PUT upload
-
Can you set logging to DEBUG and collect the logs?
https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors
Yes, if it will help. But it's clear in the code that ctx is not passed all the way down to the upload methods.
- What is your Snowflake account identifier, if any? (Optional)