Skip to content

Commit ebb1588

Browse files
authored
Add a timeout to assignEntries (transparency-dev#950)
Adds an explicit context timeout to the action of assigning indices to entries.
1 parent 8693957 commit ebb1588

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

storage/aws/aws.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ const (
8888
// compatible with the new format, and provide a means to do it if so.
8989
SchemaCompatibilityVersion = 1
9090

91+
// defaultAssignEntriesTimeout is the default context timeout applied when assigning a batch of entries to the MySQL sequencer.
92+
defaultAssignEntriesTimeout = 2 * time.Second
9193
// defaultIntegrationTimeout is the default context timeout applied when undertaking an integration task.
9294
defaultIntegrationTimeout = 10 * time.Second
9395
// defaultPublicationTimeout is the default context timeout applied when undertaking a checkpoint publication task.
@@ -242,6 +244,8 @@ func (s *Storage) newAppender(ctx context.Context, o objStore, seq sequencer, op
242244
entriesAssigned: make(chan struct{}, 1),
243245
}
244246
r.queue = storage.NewQueue(ctx, opts.BatchMaxAge(), opts.BatchMaxSize(), func(ctx context.Context, entries []*tessera.Entry) error {
247+
ctx, cancel := context.WithTimeout(ctx, defaultAssignEntriesTimeout)
248+
defer cancel()
245249
if err := r.sequencer.assignEntries(ctx, entries); err != nil {
246250
return err
247251
}

storage/gcp/gcp.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ const (
9898
// compatible with the new format, and provide a means to do it if so.
9999
SchemaCompatibilityVersion = 1
100100

101+
// defaultAssignEntriesTimeout is the default context timeout applied when assigning a batch of entries to the Spanner sequencer.
102+
defaultAssignEntriesTimeout = 2 * time.Second
101103
// defaultIntegrationTimeout is the default context timeout applied when undertaking an integration task.
102104
defaultIntegrationTimeout = 10 * time.Second
103105
// defaultPublicationTimeout is the default context timeout applied when undertaking a checkpoint publication task.
@@ -269,6 +271,8 @@ func (s *Storage) newAppender(ctx context.Context, o objStore, seq *spannerCoord
269271
entriesAssigned: make(chan struct{}, 1),
270272
}
271273
a.queue = storage.NewQueue(ctx, opts.BatchMaxAge(), opts.BatchMaxSize(), func(ctx context.Context, entries []*tessera.Entry) error {
274+
ctx, cancel := context.WithTimeout(ctx, defaultAssignEntriesTimeout)
275+
defer cancel()
272276
if err := a.sequencer.assignEntries(ctx, entries); err != nil {
273277
return err
274278
}

0 commit comments

Comments
 (0)