Skip to content

Commit 3404ff7

Browse files
committed
[FAB-6853] Fix block storage startup messages
This CR fixes some of the messages that the block storgae prints during startup. Change-Id: Iaecb2c721c3c49205e4a774947bee0995ddb2e1f Signed-off-by: manish <[email protected]> (cherry picked from commit 8a22a9f)
1 parent dc8d323 commit 3404ff7

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

common/ledger/blkstorage/fsblkstorage/blockfile_helper.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ func constructCheckpointInfoFromBlockFiles(rootDir string) (*checkpointInfo, err
3838

3939
if lastFileNum == -1 {
4040
cpInfo := &checkpointInfo{0, 0, true, 0}
41-
logger.Info("No block file found")
41+
logger.Debugf("No block file found")
4242
return cpInfo, nil
4343
}
4444

4545
fileInfo := getFileInfoOrPanic(rootDir, lastFileNum)
46-
logger.Infof("Last Block file info: FileName=[%s], FileSize=[%d]", fileInfo.Name(), fileInfo.Size())
46+
logger.Debugf("Last Block file info: FileName=[%s], FileSize=[%d]", fileInfo.Name(), fileInfo.Size())
4747
if lastBlockBytes, endOffsetLastBlock, numBlocksInFile, err = scanForLastCompleteBlock(rootDir, lastFileNum, 0); err != nil {
4848
logger.Errorf("Error while scanning last file [file num=%d]: %s", lastFileNum, err)
4949
return nil, err
@@ -52,7 +52,7 @@ func constructCheckpointInfoFromBlockFiles(rootDir string) (*checkpointInfo, err
5252
if numBlocksInFile == 0 && lastFileNum > 0 {
5353
secondLastFileNum := lastFileNum - 1
5454
fileInfo := getFileInfoOrPanic(rootDir, secondLastFileNum)
55-
logger.Infof("Second last Block file info: FileName=[%s], FileSize=[%d]", fileInfo.Name(), fileInfo.Size())
55+
logger.Debugf("Second last Block file info: FileName=[%s], FileSize=[%d]", fileInfo.Name(), fileInfo.Size())
5656
if lastBlockBytes, _, _, err = scanForLastCompleteBlock(rootDir, secondLastFileNum, 0); err != nil {
5757
logger.Errorf("Error while scanning second last file [file num=%d]: %s", secondLastFileNum, err)
5858
return nil, err

common/ledger/blkstorage/fsblkstorage/blockfile_mgr.go

+9-15
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,13 @@ func newBlockfileMgr(id string, conf *Conf, indexConfig *blkstorage.IndexConfig,
115115
panic(fmt.Sprintf("Could not get block file info for current block file from db: %s", err))
116116
}
117117
if cpInfo == nil {
118-
logger.Info(`No info about blocks file found in the db.
119-
This could happen if this is the first time the ledger is constructed or the index is dropped.
120-
Scanning blocks dir for the latest info`)
118+
logger.Info(`Getting block information from block storage`)
121119
if cpInfo, err = constructCheckpointInfoFromBlockFiles(rootDir); err != nil {
122120
panic(fmt.Sprintf("Could not build checkpoint info from block files: %s", err))
123121
}
124-
logger.Infof("Info constructed by scanning the blocks dir = %s", spew.Sdump(cpInfo))
122+
logger.Debugf("Info constructed by scanning the blocks dir = %s", spew.Sdump(cpInfo))
125123
} else {
126-
logger.Info(`Synching the info about block files`)
124+
logger.Debug(`Synching block information from block storage (if needed)`)
127125
syncCPInfoFromFS(rootDir, cpInfo)
128126
}
129127
err = mgr.saveCurrentInfo(cpInfo, true)
@@ -153,18 +151,15 @@ func newBlockfileMgr(id string, conf *Conf, indexConfig *blkstorage.IndexConfig,
153151
// or announcing the occurrence of an event.
154152
mgr.cpInfoCond = sync.NewCond(&sync.Mutex{})
155153

156-
// Verify that the index stored in db is accurate with what is actually stored in block file system
157-
// If not the same, sync the index and the file system
158-
mgr.syncIndex()
159-
160154
// init BlockchainInfo for external API's
161155
bcInfo := &common.BlockchainInfo{
162156
Height: 0,
163157
CurrentBlockHash: nil,
164158
PreviousBlockHash: nil}
165159

166-
//If start up is a restart of an existing storage, update BlockchainInfo for external API's
167160
if !cpInfo.isChainEmpty {
161+
//If start up is a restart of an existing storage, sync the index from block storage and update BlockchainInfo for external API's
162+
mgr.syncIndex()
168163
lastBlockHeader, err := mgr.retrieveBlockHeaderByNumber(cpInfo.lastBlockNumber)
169164
if err != nil {
170165
panic(fmt.Sprintf("Could not retrieve header of the last block form file: %s", err))
@@ -177,7 +172,6 @@ func newBlockfileMgr(id string, conf *Conf, indexConfig *blkstorage.IndexConfig,
177172
PreviousBlockHash: previousBlockHash}
178173
}
179174
mgr.bcInfo.Store(bcInfo)
180-
//return the new manager (blockfileMgr)
181175
return mgr
182176
}
183177

@@ -346,10 +340,10 @@ func (mgr *blockfileMgr) syncIndex() error {
346340
//if the index stored in the db has value, update the index information with those values
347341
if !indexEmpty {
348342
if lastBlockIndexed == mgr.cpInfo.lastBlockNumber {
349-
logger.Infof("Both the block files and indices are in sync.")
343+
logger.Debug("Both the block files and indices are in sync.")
350344
return nil
351345
}
352-
logger.Infof("Last block indexed [%d], Last block present in block files=[%d]", lastBlockIndexed, mgr.cpInfo.lastBlockNumber)
346+
logger.Debugf("Last block indexed [%d], Last block present in block files [%d]", lastBlockIndexed, mgr.cpInfo.lastBlockNumber)
353347
var flp *fileLocPointer
354348
if flp, err = mgr.index.getBlockLocByBlockNum(lastBlockIndexed); err != nil {
355349
return err
@@ -359,10 +353,10 @@ func (mgr *blockfileMgr) syncIndex() error {
359353
skipFirstBlock = true
360354
startingBlockNum = lastBlockIndexed + 1
361355
} else {
362-
logger.Infof("No block indexed, Last block present in block files=[%d]", mgr.cpInfo.lastBlockNumber)
356+
logger.Debugf("No block indexed, Last block present in block files=[%d]", mgr.cpInfo.lastBlockNumber)
363357
}
364358

365-
logger.Infof("Start building index from block [%d]", startingBlockNum)
359+
logger.Infof("Start building index from block [%d] to last block [%d]", startingBlockNum, mgr.cpInfo.lastBlockNumber)
366360

367361
//open a blockstream to the file location that was stored in the index
368362
var stream *blockStream

0 commit comments

Comments
 (0)