提交 fb2cbd87 编写于 作者: X xiaojianming

delete restoreIndex log

上级 c645e712
......@@ -176,7 +176,6 @@ func (indexFile *YTFSIndexFile) loadTableFromStorage(tbIndex uint32) (map[ydcomm
func (indexFile *YTFSIndexFile) ClearItemFromTable( tbidx uint32, hashKey ydcommon.IndexTableKey, btCnt uint32, tbItemMap map[uint32]uint32) error {
var err error
fmt.Printf("[ClearItemFromTable] tableindex=%v, btCnt=%v, hash=%v \n",tbidx, btCnt, base58.Encode(hashKey[:]))
writer,err := indexFile.store.Writer()
if err != nil{
fmt.Println("[ClearItemFromTable] get writer error!")
......@@ -201,10 +200,8 @@ func (indexFile *YTFSIndexFile) ClearItemFromTable( tbidx uint32, hashKey ydcomm
tableSize := binary.LittleEndian.Uint32(sizeBuf)
itemBuf := make([]byte, itemSize)
zeroBuf := make([]byte,itemSize)
fmt.Printf("[ClearItemFromTable] tableindex=%v, tablesize=%v, btCnt=%v \n", tbidx, tableSize, btCnt)
for i := tableSize; 0 <= i; i-- {
fmt.Printf("[ClearItemFromTable] tableindex=%v, tablesize=%v, btCnt=%v, i=%v\n", tbidx, tableSize, btCnt, i)
itemOffset := tableOffset+4+int64(i*itemSize)
reader.Seek(itemOffset, io.SeekStart)
reader.Read(itemBuf)
......@@ -229,12 +226,10 @@ func (indexFile *YTFSIndexFile)ResetTableSize(tbItemMap map[uint32]uint32) error
tableAllocationSize := indexFile.meta.RangeCoverage*itemSize + 4
sizeBuf := make([]byte, 4)
for tbidx,value := range tbItemMap{
fmt.Printf("[resettablesize] tbidx=%v, value=%v \n",tbidx,value)
tableOffset := int64(indexFile.meta.HashOffset)+int64(tbidx)*int64(tableAllocationSize)
reader.Seek(tableOffset,io.SeekStart)
reader.Read(sizeBuf)
tableSize := binary.LittleEndian.Uint32(sizeBuf)
fmt.Printf("[resettablesize] before reset, tbidx=%v, tablesize=%v \n",tbidx, tableSize)
tableSize = tableSize - value
writer.Seek(tableOffset,io.SeekStart)
binary.LittleEndian.PutUint32(sizeBuf, tableSize)
......
......@@ -3,12 +3,10 @@ package ytfs
import (
"encoding/json"
"fmt"
"time"
// "github.com/linux-go/go1.13.5.linux-amd64/go/src/time"
"github.com/mr-tron/base58/base58"
"github.com/yottachain/YTDataNode/util"
ydcommon "github.com/yottachain/YTFS/common"
"github.com/yottachain/YTFS/errors"
"github.com/yottachain/YTFS/opt"
_ "net/http/pprof"
"os"
......@@ -208,17 +206,14 @@ func (ytfs *YTFS) restoreYTFS() {
func (ytfs *YTFS) restoreIndex(conflict map[ydcommon.IndexTableKey]byte, batchindex []ydcommon.IndexItem, btCnt uint32) error {
var err error
fmt.Println("[restoreIndex] start")
tbItemMap := make(map[uint32]uint32,btCnt)
for _, kvPairs := range batchindex {
hashkey := kvPairs.Hash
fmt.Println("[restoreIndex] restore hashkey:",base58.Encode(hashkey[:]))
if _, ok := conflict[hashkey]; ok{
fmt.Println("[restoreIndex] hashkey conflict:",base58.Encode(hashkey[:]))
continue
}
idx := ytfs.db.indexFile.GetTableEntryIndex(hashkey)
fmt.Printf("[restoreIndex] tableindex=%v \n",idx)
err = ytfs.db.indexFile.ClearItemFromTable(idx, hashkey,btCnt,tbItemMap)
if err != nil {
fmt.Printf("[restoreIndex] reset tableidx %v hashkey %v \n",idx,hashkey)
......@@ -229,7 +224,6 @@ func (ytfs *YTFS) restoreIndex(conflict map[ydcommon.IndexTableKey]byte, batchin
if err != nil {
fmt.Println("[restoreIndex] ResetTableSize error")
}
fmt.Println("[restoreIndex] end")
return err
}
......@@ -271,7 +265,7 @@ func (ytfs *YTFS)checkConflicts(conflicts map[ydcommon.IndexTableKey]byte, batch
}
}
var mutexindex uint64 = 0
//var mutexindex uint64 = 0
// BatchPut sets the value array for the given key array.
// It panics if there exists any previous value for that key as YottaDisk is not a multi-map.
// It is safe to modify the contents of the arguments after Put returns but not
......@@ -280,7 +274,6 @@ func (ytfs *YTFS) BatchPut(batch map[ydcommon.IndexTableKey][]byte) (map[ydcommo
ytfs.mutex.Lock()
defer ytfs.mutex.Unlock()
fmt.Printf("[mutexlocked] ytfs batchput lock %v \n",mutexindex)
if len(batch) > 1000 {
return nil, fmt.Errorf("Batch Size is too big")
}
......@@ -314,30 +307,10 @@ func (ytfs *YTFS) BatchPut(batch map[ydcommon.IndexTableKey][]byte) (map[ydcommo
conflicts, err := ytfs.db.BatchPut(batchIndexes)
defer ytfs.checkConflicts(conflicts, batch) //todo xiaojm
if err != nil {
ytfs.restoreYTFS()
ytfs.restoreIndex(conflicts, batchIndexes, uint32(bufCnt))
fmt.Printf("[mutexunlocked] ytfs batchput unlock %v \n",mutexindex)
mutexindex++
if mutexindex % 1000 == 0 {
time.Sleep(time.Second * 15)
}
return conflicts, err
}
fmt.Printf("[mutexunlocked] ytfs batchput unlock %v \n",mutexindex)
mutexindex++
if mutexindex % 1000 == 0 {
time.Sleep(time.Second * 15)
}
if mutexindex % 2099 == 0 {
ytfs.restoreYTFS()
ytfs.restoreIndex(conflicts, batchIndexes, uint32(bufCnt))
fmt.Printf("[error_injection] %v \n",mutexindex)
return conflicts, errors.ErrRangeFull
return conflicts, err
}
return nil, nil
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册