-
Notifications
You must be signed in to change notification settings - Fork 23
fix(writemarker):improved ReddemWriteMarkers to fix #624 #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
40c842f
fix(writemarker):improved ReddemWriteMarkers to fix #624
cnlangzi e358b54
fix(writemarker):improved logging importing for #624
cnlangzi 490018d
fix(writemarker):removed recorver code on #624
cnlangzi ee7306d
Merge branch 'staging' into fix/panicking_on_wm
cnlangzi e69c130
fix(writemarker):smaller transaction on redeem WM for #624
cnlangzi be5d9cf
fix(writemarker):smaller transaction on redeem WM for #624
cnlangzi 019d3fc
fix(writemarker):smaller transaction on redeem WM for #624
cnlangzi 239e104
Merge branch 'staging' into fix/panicking_on_wm
cnlangzi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,27 @@ | ||
package writemarker | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/allocation" | ||
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/config" | ||
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/datastore" | ||
"github.com/0chain/blobber/code/go/0chain.net/core/logging" | ||
"github.com/remeh/sizedwaitgroup" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func redeemWriteMarker(ctx context.Context) { | ||
defer func() { | ||
if r := recover(); r != nil { | ||
logging.Logger.Error("[recover] redeemWriteMarker", zap.Any("err", r)) | ||
} | ||
}() | ||
func redeemWriteMarkers() { | ||
|
||
rctx := datastore.GetStore().CreateTransaction(ctx) | ||
db := datastore.GetStore().GetTransaction(rctx) | ||
allocations := make([]*allocation.Allocation, 0) | ||
alloc := &allocation.Allocation{IsRedeemRequired: true} | ||
db.Where(alloc).Find(&allocations) | ||
db := datastore.GetStore().GetDB() | ||
var allocations []*allocation.Allocation | ||
db.Where(&allocation.Allocation{IsRedeemRequired: true}). | ||
Find(&allocations) | ||
if len(allocations) > 0 { | ||
swg := sizedwaitgroup.New(config.Configuration.WMRedeemNumWorkers) | ||
for _, allocationObj := range allocations { | ||
swg.Add() | ||
go func(redeemCtx context.Context, allocationObj *allocation.Allocation) { | ||
err := RedeemMarkersForAllocation(redeemCtx, allocationObj) | ||
if err != nil { | ||
logging.Logger.Error("Error redeeming the write marker for allocation.", zap.Any("allocation", allocationObj.ID), zap.Error(err)) | ||
} | ||
go func(allocationObj *allocation.Allocation) { | ||
redeemWriterMarkersForAllocation(allocationObj) | ||
swg.Done() | ||
}(ctx, allocationObj) | ||
}(allocationObj) | ||
} | ||
swg.Wait() | ||
} | ||
db.Rollback() | ||
rctx.Done() | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.