Skip to content

bigquery/storage: ManagedStream should not hold context.Canceled and context.DeadlineExceeded error #6657

@tamayika

Description

@tamayika

Client

BigQuery/Storage

Environment

Any

Go Environment

Any

Code

package main

func main() {
	/* initialization skipped */
	// this repro uses context.WithCancel(), but the same happens on context.WithTimeout() and context.DeadlineExceeded
	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		// wait to ManagedStream.lockingAppend()
		time.Sleep(100 * time.Millisecond)
		cancel()
	}()
	_, err := stream.AppendRows(ctx, bytes)                 // context.Canceled is returned: expected
	_, err = stream.AppendRows(context.Background(), bytes) // context.Canceled is returned: unexpected
}

This problem is race condition, so please add time.Sleep(1 * time.Second) to https://github.com/googleapis/google-cloud-go/blob/main/bigquery/storage/managedwriter/managed_stream.go#L266

Expected behavior

ManagedStream does not hold context error.

Actual behavior

ManagedStream holds context error.

Screenshots

Additional context

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions