Skip to content

Commit

Permalink
remove retry count from dag message.
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf committed Jun 13, 2024
1 parent c67b272 commit 10e35c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 0 additions & 2 deletions events/dag_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ type DAGMerge struct {
// Wg is a wait group that can be used to synchronize the merge,
// allowing the caller to optionnaly block until the merge is complete.
Wg *sync.WaitGroup
// RetryCount is the number of times this merge has been retried due to a conflict.
RetryCount int
}
23 changes: 15 additions & 8 deletions internal/db/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,26 @@ func (db *db) handleMerges(ctx context.Context, merges events.Subscription[event
queue.add(merge.DocID)
defer queue.done(merge.DocID)

var err error
// retry merge up to max txn retries
for i := 0; i < db.MaxTxnRetries(); i++ {
err := db.executeMerge(ctx, merge)
err = db.executeMerge(ctx, merge)
if errors.Is(err, badger.ErrTxnConflict) {
continue // retry merge
}
if err != nil {
log.ErrorContextE(ctx, "Failed to execute merge", err, corelog.Any("Merge", merge))
}
if merge.Wg != nil {
merge.Wg.Done()
}
break // merge completed
break // merge success or error
}

if err != nil {
log.ErrorContextE(
ctx,
"Failed to execute merge",
err,
corelog.Any("Error", err),
corelog.Any("Event", merge))

Check warning on line 68 in internal/db/merge.go

View check run for this annotation

Codecov / codecov/patch

internal/db/merge.go#L67-L68

Added lines #L67 - L68 were not covered by tests
}
if merge.Wg != nil {
merge.Wg.Done()
}
}()
}
Expand Down

0 comments on commit 10e35c3

Please sign in to comment.