Skip to content

Commit 67afa96

Browse files
Bigtable: Retry GC policy operations with a longer poll interval (#6627) (#12717)
Co-authored-by: Riley Karson <[email protected]> Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]> Co-authored-by: Riley Karson <[email protected]>
1 parent c06396c commit 67afa96

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

.changelog/6627.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
bigtable: retry GC policy operations with a longer poll interval
3+
```

google/resource_bigtable_gc_policy.go

+17-6
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,17 @@ func resourceBigtableGCPolicyUpsert(d *schema.ResourceData, meta interface{}) er
202202
tableName := d.Get("table").(string)
203203
columnFamily := d.Get("column_family").(string)
204204

205-
err = retryTimeDuration(func() error {
205+
retryFunc := func() (interface{}, error) {
206206
reqErr := c.SetGCPolicy(ctx, tableName, columnFamily, gcPolicy)
207-
return reqErr
208-
}, d.Timeout(schema.TimeoutCreate), isBigTableRetryableError)
207+
return "", reqErr
208+
}
209+
// The default create timeout is 20 minutes.
210+
timeout := d.Timeout(schema.TimeoutCreate)
211+
pollInterval := time.Duration(30) * time.Second
212+
// Mutations to gc policies can only happen one-at-a-time and take some amount of time.
213+
// Use a fixed polling rate of 30s based on the RetryInfo returned by the server rather than
214+
// the standard up-to-10s exponential backoff for those operations.
215+
_, err = retryWithPolling(retryFunc, timeout, pollInterval, isBigTableRetryableError)
209216
if err != nil {
210217
return err
211218
}
@@ -376,10 +383,14 @@ func resourceBigtableGCPolicyDestroy(d *schema.ResourceData, meta interface{}) e
376383

377384
defer c.Close()
378385

379-
err = retryTimeDuration(func() error {
386+
retryFunc := func() (interface{}, error) {
380387
reqErr := c.SetGCPolicy(ctx, d.Get("table").(string), d.Get("column_family").(string), bigtable.NoGcPolicy())
381-
return reqErr
382-
}, d.Timeout(schema.TimeoutDelete), isBigTableRetryableError)
388+
return "", reqErr
389+
}
390+
// The default delete timeout is 20 minutes.
391+
timeout := d.Timeout(schema.TimeoutDelete)
392+
pollInterval := time.Duration(30) * time.Second
393+
_, err = retryWithPolling(retryFunc, timeout, pollInterval, isBigTableRetryableError)
383394
if err != nil {
384395
return err
385396
}

0 commit comments

Comments
 (0)