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

Query cancellation fix #148

Merged
merged 5 commits into from
Feb 1, 2024
Merged

Conversation

k-anshul
Copy link
Contributor

@k-anshul k-anshul commented Jan 17, 2024

Hey @marcboeker

Found one tricky issue in the query cancellation that we had discussed previously.
It is easy to reproduce when query completes quickly like in case of in-memory DB and checkpoint query. Example below:

func main() {
	db, err := sql.Open("duckdb", "")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	conn, err := db.Conn(context.Background())
	if err != nil {
		log.Fatal(err)
	}

	var wg sync.WaitGroup
	wg.Add(100)
	for i := 0; i < 100; i++ {
		v := i
		go func() {
			ctx, cancel := context.WithCancel(context.Background())
			defer cancel()
			defer wg.Done()
			_, err = conn.ExecContext(ctx, "CHECKPOINT;")
			if err != nil {
				log.Printf("err %v", err)
			}
			fmt.Printf("iteration %v done\n", v)
		}()
	}
	wg.Wait()
}

cc : @begelundmuller

@k-anshul k-anshul marked this pull request as ready for review January 19, 2024 07:30
@k-anshul
Copy link
Contributor Author

k-anshul commented Feb 1, 2024

Hey @marcboeker

Just nudging in case this missed your radar.

@marcboeker marcboeker merged commit 2f01e5b into marcboeker:main Feb 1, 2024
3 checks passed
@marcboeker
Copy link
Owner

@k-anshul Thanks for the ping. Missed the change from draft to ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants