Skip to content

Commit

Permalink
fixed 10490
Browse files Browse the repository at this point in the history
  • Loading branch information
dvovk committed May 28, 2024
1 parent db2e5d3 commit 7081c0f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
8 changes: 8 additions & 0 deletions erigon-lib/diagnostics/snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ func ReadSnapshotDownloadInfo(db kv.RoDB) (info SnapshotDownloadStatistics) {
data := ReadDataFromTable(db, kv.DiagSyncStages, SnapshotDownloadStatisticsKey)
err := json.Unmarshal(data, &info)

if len(data) == 0 {
return SnapshotDownloadStatistics{}
}

if err != nil {
log.Error("[Diagnostics] Failed to read snapshot download info", "err", err)
return SnapshotDownloadStatistics{}
Expand All @@ -315,6 +319,10 @@ func ReadSnapshotIndexingInfo(db kv.RoDB) (info SnapshotIndexingStatistics) {
data := ReadDataFromTable(db, kv.DiagSyncStages, SnapshotIndexingStatisticsKey)
err := json.Unmarshal(data, &info)

if len(data) == 0 {
return SnapshotIndexingStatistics{}
}

if err != nil {
log.Error("[Diagnostics] Failed to read snapshot indexing info", "err", err)
return SnapshotIndexingStatistics{}
Expand Down
12 changes: 10 additions & 2 deletions erigon-lib/diagnostics/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ func ReadStagesList(db kv.RoDB) []string {
var info []string
err := json.Unmarshal(data, &info)

if len(data) == 0 {
return []string{}
}

if err != nil {
log.Error("[Diagnostics] Failed to read stages list", "err", err)
return []string{}
Expand All @@ -92,10 +96,14 @@ func ReadStagesList(db kv.RoDB) []string {
}

func ReadCurrentStage(db kv.RoDB) uint {
data := ReadDataFromTable(db, kv.DiagSyncStages, StagesListKey)
data := ReadDataFromTable(db, kv.DiagSyncStages, CurrentStageKey)
var info uint
err := json.Unmarshal(data, &info)

if len(data) == 0 {
return 0
}

if err != nil {
log.Error("[Diagnostics] Failed to read current stage", "err", err)
return 0
Expand All @@ -109,5 +117,5 @@ func StagesListUpdater(info []string) func(tx kv.RwTx) error {
}

func CurrentStageUpdater(info uint) func(tx kv.RwTx) error {
return PutDataToTable(kv.DiagSyncStages, StagesListKey, info)
return PutDataToTable(kv.DiagSyncStages, CurrentStageKey, info)
}
12 changes: 12 additions & 0 deletions erigon-lib/diagnostics/sys_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func ReadRAMInfo(db kv.RoDB) RAMInfo {
var info RAMInfo
err := json.Unmarshal(data, &info)

if len(data) == 0 {
return RAMInfo{}
}

if err != nil {
log.Error("[Diagnostics] Failed to read RAM info", "err", err)
return RAMInfo{}
Expand All @@ -158,6 +162,10 @@ func ReadCPUInfo(db kv.RoDB) CPUInfo {
var info CPUInfo
err := json.Unmarshal(data, &info)

if len(data) == 0 {
return CPUInfo{}
}

if err != nil {
log.Error("[Diagnostics] Failed to read CPU info", "err", err)
return CPUInfo{}
Expand All @@ -171,6 +179,10 @@ func ReadDickInfo(db kv.RoDB) DiskInfo {
var info DiskInfo
err := json.Unmarshal(data, &info)

if len(data) == 0 {
return DiskInfo{}
}

if err != nil {
log.Error("[Diagnostics] Failed to read Disk info", "err", err)
return DiskInfo{}
Expand Down

0 comments on commit 7081c0f

Please sign in to comment.