Skip to content

Commit 7f8d69d

Browse files
authored
fix(storage): clone the defaultRetry to avoid modifying it directly (#11533)
Fixes #11531 Also moved this code since it doesn't need to be done in the loop.
1 parent a299db2 commit 7f8d69d

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

storage/grpc_client.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,15 @@ func (c *grpcStorageClient) OpenWriter(params *openWriterParams, opts ...storage
16981698

16991699
s := callSettings(c.settings, opts...)
17001700

1701+
retryDeadline := defaultWriteChunkRetryDeadline
1702+
if params.chunkRetryDeadline != 0 {
1703+
retryDeadline = params.chunkRetryDeadline
1704+
}
1705+
if s.retry == nil {
1706+
s.retry = defaultRetry.clone()
1707+
}
1708+
s.retry.maxRetryDuration = retryDeadline
1709+
17011710
// This function reads the data sent to the pipe and sends sets of messages
17021711
// on the gRPC client-stream as the buffer is filled.
17031712
go func() {
@@ -1723,16 +1732,6 @@ func (c *grpcStorageClient) OpenWriter(params *openWriterParams, opts ...storage
17231732
return err
17241733
}
17251734

1726-
retryDeadline := defaultWriteChunkRetryDeadline
1727-
if params.chunkRetryDeadline != 0 {
1728-
retryDeadline = params.chunkRetryDeadline
1729-
}
1730-
1731-
if gw.settings.retry == nil {
1732-
gw.settings.retry = defaultRetry
1733-
}
1734-
gw.settings.retry.maxRetryDuration = retryDeadline
1735-
17361735
var o *storagepb.Object
17371736
uploadBuff := func(ctx context.Context) error {
17381737
obj, err := gw.uploadBuffer(ctx, recvd, offset, doneReading)

0 commit comments

Comments
 (0)