fix(client): remove debug log

close:#1000101999

Signed-off-by: chihe <chihe@oppo.com>
This commit is contained in:
chihe 2025-05-07 16:04:22 +08:00 committed by zhumingze1108
parent 206937fd96
commit 94fd8c6618
3 changed files with 23 additions and 23 deletions

View File

@ -142,7 +142,7 @@ func IsDiskErr(errMsg string) bool {
}
// WriteAt writes data to an cacheBlock, only append write supported
func (cb *CacheBlock) WriteAt(data []byte, offset, size int64, reqID int64) (err error) {
func (cb *CacheBlock) WriteAt(data []byte, offset, size int64) (err error) {
var file *os.File
bgTime := stat.BeginStat()
startTime := time.Now()
@ -160,7 +160,7 @@ func (cb *CacheBlock) WriteAt(data []byte, offset, size int64, reqID int64) (err
}
}()
if alloced := cb.getAllocSize(); offset >= alloced || size == 0 || offset+size > alloced {
return fmt.Errorf("reqID %v parameter offset=%d size=%d allocSize:%d", reqID, offset, size, alloced)
return fmt.Errorf("parameter offset=%d size=%d allocSize:%d", offset, size, alloced)
}
if file, err = cb.GetOrOpenFileHandler(); err != nil {
@ -300,7 +300,7 @@ func (cb *CacheBlock) checkCacheBlockFileHeader(file *os.File) (allocSize, usedS
return
}
func (cb *CacheBlock) initFilePath(isLoad bool, reqID int64) (err error) {
func (cb *CacheBlock) initFilePath(isLoad bool) (err error) {
defer func() {
if err != nil {
if IsDiskErr(err.Error()) {
@ -362,14 +362,14 @@ func (cb *CacheBlock) initFilePath(isLoad bool, reqID int64) (err error) {
}
_, err = os.Stat(cb.filePath)
if !isLoad {
msg := fmt.Sprintf("init cache block(%s) to local reqID %v: err %v", cb.info(), reqID, err)
msg := fmt.Sprintf("init cache block(%s) to local: err %v", cb.info(), err)
log.LogDebugf("%v", msg)
auditlog.LogFlashNodeOp("BlockInit", msg, err)
}
return
}
func (cb *CacheBlock) Init(sources []*proto.DataSource, readDataNodeTimeout int, reqID int64) {
func (cb *CacheBlock) Init(sources []*proto.DataSource, readDataNodeTimeout int) {
var err error
var file *os.File
bgTime := stat.BeginStat()
@ -395,7 +395,7 @@ func (cb *CacheBlock) Init(sources []*proto.DataSource, readDataNodeTimeout int,
for i := 0; i < util.Min(20, len(sources)); i++ {
wg.Add(1)
go func() {
if err := cb.prepareSource(ctx, sourceTaskCh, readDataNodeTimeout, reqID); err != nil {
if err := cb.prepareSource(ctx, sourceTaskCh, readDataNodeTimeout); err != nil {
cancel()
}
wg.Done()
@ -439,7 +439,7 @@ func (cb *CacheBlock) Init(sources []*proto.DataSource, readDataNodeTimeout int,
cb.notifyReady()
}
func (cb *CacheBlock) prepareSource(ctx context.Context, sourceCh <-chan *proto.DataSource, readDataNodeTimeout int, reqID int64) (err error) {
func (cb *CacheBlock) prepareSource(ctx context.Context, sourceCh <-chan *proto.DataSource, readDataNodeTimeout int) (err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("CacheBlock:prepareSource", err, bgTime, 1)
@ -454,7 +454,7 @@ func (cb *CacheBlock) prepareSource(ctx context.Context, sourceCh <-chan *proto.
}
offset := int64(source.FileOffset) & (proto.CACHE_BLOCK_SIZE - 1)
writeCacheAfterRead := func(data []byte, size int64) error {
if e := cb.WriteAt(data, offset, size, reqID); e != nil {
if e := cb.WriteAt(data, offset, size); e != nil {
return e
}
offset += size
@ -522,8 +522,8 @@ func computeAllocSize(sources []*proto.DataSource) (alloc uint64) {
return
}
func (cb *CacheBlock) InitOnce(engine *CacheEngine, sources []*proto.DataSource, reqID int64) {
cb.initOnce.Do(func() { cb.Init(sources, engine.readDataNodeTimeout, reqID) })
func (cb *CacheBlock) InitOnce(engine *CacheEngine, sources []*proto.DataSource) {
cb.initOnce.Do(func() { cb.Init(sources, engine.readDataNodeTimeout) })
select {
case <-cb.closeCh:
engine.deleteCacheBlock(cb.blockKey)
@ -563,9 +563,9 @@ func (cb *CacheBlock) GetRootPath() string {
return cb.rootPath
}
func (cb *CacheBlock) InitOnceForCacheRead(engine *CacheEngine, sources []*proto.DataSource, done chan struct{}, reqID int64) {
func (cb *CacheBlock) InitOnceForCacheRead(engine *CacheEngine, sources []*proto.DataSource, done chan struct{}) {
cb.initOnce.Do(func() {
cb.InitForCacheRead(sources, engine.readDataNodeTimeout, reqID)
cb.InitForCacheRead(sources, engine.readDataNodeTimeout)
select {
case <-cb.closeCh:
engine.deleteCacheBlock(cb.blockKey)
@ -576,7 +576,7 @@ func (cb *CacheBlock) InitOnceForCacheRead(engine *CacheEngine, sources []*proto
close(done)
}
func (cb *CacheBlock) InitForCacheRead(sources []*proto.DataSource, readDataNodeTimeout int, reqID int64) {
func (cb *CacheBlock) InitForCacheRead(sources []*proto.DataSource, readDataNodeTimeout int) {
var err error
var file *os.File
bgTime := stat.BeginStat()
@ -598,7 +598,7 @@ func (cb *CacheBlock) InitForCacheRead(sources []*proto.DataSource, readDataNode
for _, s := range sources {
offset := int64(s.FileOffset) & (proto.CACHE_BLOCK_SIZE - 1)
writeCacheAfterRead := func(data []byte, size int64) error {
if e := cb.WriteAt(data, offset, size, reqID); e != nil {
if e := cb.WriteAt(data, offset, size); e != nil {
return e
}
offset += size

View File

@ -604,7 +604,7 @@ func (c *CacheEngine) createCacheBlockFromExist(dataPath string, volume string,
}
}()
if err = block.initFilePath(true, 0); err != nil {
if err = block.initFilePath(true); err != nil {
return
}
@ -616,7 +616,7 @@ func (c *CacheEngine) createCacheBlockFromExist(dataPath string, volume string,
return
}
func (c *CacheEngine) createCacheBlock(volume string, inode, fixedOffset uint64, version uint32, ttl int64, allocSize uint64, clientIP string, isPrepare bool, reqID int64) (block *CacheBlock, err error) {
func (c *CacheEngine) createCacheBlock(volume string, inode, fixedOffset uint64, version uint32, ttl int64, allocSize uint64, clientIP string, isPrepare bool) (block *CacheBlock, err error) {
if allocSize == 0 {
return nil, fmt.Errorf("alloc size is zero")
}
@ -684,7 +684,7 @@ func (c *CacheEngine) createCacheBlock(volume string, inode, fixedOffset uint64,
return
}
if err = block.initFilePath(false, reqID); err != nil {
if err = block.initFilePath(false); err != nil {
return
}
if _, err = cacheItem.lruCache.Set(key, block, time.Duration(ttl)*time.Second); err != nil {
@ -732,7 +732,7 @@ func (c *CacheEngine) startCachePrepareWorkers() {
return
case task := <-c.cachePrepareTaskCh:
r := task.request
if _, err := c.CreateBlock(r, task.clientIP, true, task.reqID); err != nil {
if _, err := c.CreateBlock(r, task.clientIP, true); err != nil {
log.LogWarnf("action[startCachePrepareWorkers] ReqID(%d) create block failed, err:%v", task.reqID, err)
continue
}
@ -740,7 +740,7 @@ func (c *CacheEngine) startCachePrepareWorkers() {
if err != nil {
log.LogWarnf("action[startCachePrepareWorkers] ReqID(%d) cache block not found, err:%v", task.reqID, err)
} else {
block.InitOnce(c, r.Sources, task.reqID)
block.InitOnce(c, r.Sources)
}
}
}
@ -757,11 +757,11 @@ func (c *CacheEngine) PrepareCache(reqID int64, req *proto.CacheRequest, clientI
return
}
func (c *CacheEngine) CreateBlock(req *proto.CacheRequest, clientIP string, isPrepare bool, reqID int64) (block *CacheBlock, err error) {
func (c *CacheEngine) CreateBlock(req *proto.CacheRequest, clientIP string, isPrepare bool) (block *CacheBlock, err error) {
if len(req.Sources) == 0 {
return nil, fmt.Errorf("no source data")
}
if block, err = c.createCacheBlock(req.Volume, req.Inode, req.FixedFileOffset, req.Version, req.TTL, computeAllocSize(req.Sources), clientIP, isPrepare, reqID); err != nil {
if block, err = c.createCacheBlock(req.Volume, req.Inode, req.FixedFileOffset, req.Version, req.TTL, computeAllocSize(req.Sources), clientIP, isPrepare); err != nil {
log.LogWarnf("action[CreateBlock] createCacheBlock(%v) failed err %v ",
GenCacheBlockKey(req.Volume, req.Inode, req.FixedFileOffset, req.Version), err)
c.deleteCacheBlock(GenCacheBlockKey(req.Volume, req.Inode, req.FixedFileOffset, req.Version))

View File

@ -194,12 +194,12 @@ func (f *FlashNode) opCacheRead(conn net.Conn, p *proto.Packet) (err error) {
reqSize += int(source.Size_)
}
if err = f.limitWrite.TryRunAsync(ctx, reqSize, f.waitForCacheBlock, func() {
if block2, err2 := f.cacheEngine.CreateBlock(cr, conn.RemoteAddr().String(), false, p.ReqID); err2 != nil {
if block2, err2 := f.cacheEngine.CreateBlock(cr, conn.RemoteAddr().String(), false); err2 != nil {
log.LogWarnf("opCacheRead: CreateBlock failed, req(%v) err(%v)", req, err2)
close(missTaskDone)
return
} else {
block2.InitOnceForCacheRead(f.cacheEngine, cr.Sources, missTaskDone, p.ReqID)
block2.InitOnceForCacheRead(f.cacheEngine, cr.Sources, missTaskDone)
}
}); err != nil {
stat.EndStat("MissCacheReadLimit", err, bgTime2, 1)