Skip to content

Commit d77106c

Browse files
Merge pull request #6239 from oasisprotocol/martin/bugfix/storage-sync
go/worker/storage/committee: Fix Stuck Storage Finalization
2 parents 69f0d29 + 9ea6450 commit d77106c

4 files changed

Lines changed: 136 additions & 135 deletions

File tree

.changelog/6239.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go/worker/storage/committee: Fix stuck storage finalization

go/storage/mkvs/db/api/api.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ import (
1010
"github.com/oasisprotocol/oasis-core/go/storage/mkvs/writelog"
1111
)
1212

13-
// ModuleName is the module name.
14-
const ModuleName = "storage/mkvs/db"
13+
const (
14+
// ModuleName is the module name.
15+
ModuleName = "storage/mkvs/db"
16+
17+
// MaxPendingVersions is the maximum number of allowed non-finalized versions.
18+
// Increasing this too much can result in the metadata growing too much.
19+
MaxPendingVersions = 5000
20+
)
1521

1622
var (
1723
// ErrNodeNotFound indicates that a node with the specified hash couldn't be found

go/storage/mkvs/db/pathbadger/metadata.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import (
1212
"github.com/oasisprotocol/oasis-core/go/storage/mkvs/db/api"
1313
)
1414

15-
// maxPendingVersions is the maximum number of allowed non-finalized versions. Increasing this too
16-
// much can result in the metadata growing too much.
17-
const maxPendingVersions = 5000
18-
1915
// serializedMetadata is the on-disk serialized metadata.
2016
type serializedMetadata struct {
2117
// Version is the database schema version.
@@ -123,7 +119,7 @@ func (m *metadata) reserveRootSeqNo(version uint64, rootType uint8) (uint16, err
123119
m.Lock()
124120
defer m.Unlock()
125121

126-
if len(m.value.NextPendingRootSeq) >= maxPendingVersions {
122+
if len(m.value.NextPendingRootSeq) > api.MaxPendingVersions {
127123
return math.MaxUint16, fmt.Errorf("mkvs/pathbadger: too many non-finalized versions")
128124
}
129125

@@ -146,7 +142,7 @@ func (m *metadata) setPendingRootSeqNo(version uint64, rootHash api.TypedHash, s
146142
m.Lock()
147143
defer m.Unlock()
148144

149-
if len(m.value.PendingRootSeqs) >= maxPendingVersions {
145+
if len(m.value.PendingRootSeqs) > api.MaxPendingVersions {
150146
return fmt.Errorf("mkvs/pathbadger: too many non-finalized versions")
151147
}
152148

0 commit comments

Comments
 (0)