Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

关于supernode中processCacheByQuick的疑问 #1522

Open
jack5105 opened this issue Dec 10, 2020 · 3 comments
Open

关于supernode中processCacheByQuick的疑问 #1522

jack5105 opened this issue Dec 10, 2020 · 3 comments

Comments

@jack5105
Copy link

Question

通过supernode下载了一次文件,supernode会把文件缓存到磁盘,并记录meta和md5。如果把supernode关掉再重开,再次请求同一文件,supernode会从缓存中加载文件。
我在实测中发现,supernode会出现下述log:
2020-12-10 17:02:40.698 ERRO sign:19254 : failed to process cache by quick taskID(27a30b928b929b57bdb8c4d96b046f24912bc107034c06a2abcc37784dabc984): failed to get key 27a30b928b929b57bdb8c4d96b046f24912bc107034c06a2abcc37784dabc984 from map: failed to get key 27a30b928b929b57bdb8c4d96b046f24912bc107034c06a2abcc37784dabc984 from map: {"Code":0,"Msg":"data not found"}

查看了源码,是因为在processCacheByQuick函数中,执行getPieceMD5sByTaskID时,在map中查不到key所致,这在supernode重启后是必然的,此处错误发生后会重新读取磁盘中的缓存文件并计算一遍md5。但是在这处代码下面有readPieceMD5s,可以从缓存的md5文件中取出md5进行快速校验,但是因为已经发生错误,不会执行这一步。
我想知道,作者原本的设计,在supernode重启后,是想对md5进行快速校验,还是重新对缓存文件计算一遍md5?

@244372610
Copy link
Contributor

这个地方是代码的问题,后面会先判断内存中是否有对应的piece信息,如果没有的话会去从文件中读

@starnop
Copy link
Contributor

starnop commented Dec 11, 2020

@244372610 You are right, and would you like to submit a PR to fix this problem? 😄

@244372610
Copy link
Contributor

@starnop my pleasure

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants