Skip to content

Commit 26f92d5

Browse files
committed
fix rollback and add logs
1 parent 8c2d7c8 commit 26f92d5

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

code/go/0chain.net/blobbercore/handler/object_operation_handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,7 @@ func (fsh *StorageHandler) CommitWriteV2(ctx context.Context, r *http.Request) (
10471047
ctx, writeMarker.AllocationRoot, clientKey, &numFiles, maxFiles, writeMarker.Timestamp, trie)
10481048
defer func() {
10491049
if !commitSuccess {
1050+
logging.Logger.Error("Rolling back the changes", zap.String("allocation_id", allocationID))
10501051
trie.Rollback()
10511052
}
10521053
}()
@@ -1073,10 +1074,12 @@ func (fsh *StorageHandler) CommitWriteV2(ctx context.Context, r *http.Request) (
10731074
}
10741075

10751076
if writemarkerEntity.WM.Size != size {
1076-
return nil, common.NewError("write_marker_validation_failed", fmt.Sprintf("Write Marker size %v does not match the connection size %v", writemarkerEntity.WM.Size, connectionObj.Size))
1077+
logging.Logger.Error("write_marker_validation_failed", zap.Any("write_marker_size", writemarkerEntity.WM.Size), zap.Any("connection_size", size), zap.String("allocation_id", allocationId))
1078+
return nil, common.NewError("write_marker_validation_failed", fmt.Sprintf("Write Marker size %v does not match the connection size %v", writemarkerEntity.WM.Size, size))
10771079
}
10781080

10791081
if latestWriteMarkerEntity != nil && latestWriteMarkerEntity.WM.ChainSize+size != writeMarker.ChainSize {
1082+
logging.Logger.Error("write_marker_validation_failed", zap.Any("write_marker_size", latestWriteMarkerEntity.WM.ChainSize+size), zap.Any("connection_size", writeMarker.ChainSize), zap.String("allocation_id", allocationId))
10801083
return nil, common.NewErrorf("invalid_chain_size",
10811084
"Invalid chain size. expected:%v got %v", latestWriteMarkerEntity.WM.ChainSize+connectionObj.Size, writeMarker.ChainSize)
10821085
} else if latestWriteMarkerEntity == nil && size != writeMarker.ChainSize {

code/go/0chain.net/blobbercore/handler/storage_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,8 @@ func (fsh *StorageHandler) getReferencePathV2(ctx context.Context, r *http.Reque
708708
return
709709
}
710710
allocMu := lock.GetMutex(allocation.Allocation{}.TableName(), allocationId)
711-
allocMu.Lock()
712-
defer allocMu.Unlock()
711+
allocMu.RLock()
712+
defer allocMu.RUnlock()
713713
now := time.Now()
714714

715715
trie := allocationObj.GetTrie()

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ require (
9999
)
100100

101101
require (
102-
github.com/0chain/common v1.13.1-0.20240925093917-2680c8c6a0b0
102+
github.com/0chain/common v1.13.1-0.20240925133253-58c8bc6998a6
103103
github.com/Luzifer/go-openssl/v3 v3.1.0 // indirect
104104
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
105105
github.com/btcsuite/btcd v0.23.4 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
3636
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
3737
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
3838
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
39-
github.com/0chain/common v1.13.1-0.20240925093917-2680c8c6a0b0 h1:WCHBXOjYtRWRwb5WtkWg94YTphMsi++HBE+EvdovxVE=
40-
github.com/0chain/common v1.13.1-0.20240925093917-2680c8c6a0b0/go.mod h1:vHK9Q0/nz28PxmKsLSMLzEs5iK6QVgl1LxdDQdR7y6s=
39+
github.com/0chain/common v1.13.1-0.20240925133253-58c8bc6998a6 h1:uYldZV/FDaZfT44IcNil4a4ipWS6afiiT4Efv22Jza8=
40+
github.com/0chain/common v1.13.1-0.20240925133253-58c8bc6998a6/go.mod h1:vHK9Q0/nz28PxmKsLSMLzEs5iK6QVgl1LxdDQdR7y6s=
4141
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
4242
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
4343
github.com/0chain/gosdk v1.17.0-RC6 h1:NB4pfu0VbVWfQQEfnFqn5inaiQuyhSaUW7VwgH3LW8U=

0 commit comments

Comments
 (0)