The above code extract is from core/commands/storage/contracts/contracts.go function GetUpdatedGuardContractsForRenter.
The ListRenterFileInfo API is likely ignoring RequestPageSize and/or RequestPageIndex parameter. Because of this, once the page length is reached, the API instead of returning 100 files on page index 0 and the rest on page index 1 is always returning all files. Because of it, once 100 files are reached, the break condition
does not work and the function is stacked in an infinite loop until timeout is reached. Then, because of the timeout, the rest of the process is not executed and no contracts are loaded.
In addition, the loop is continuing running in the background even after the command is terminated due to timeout and if the same command is issued multiple times, BTFS daemon is consuming more and more resources and needs to be killed.
Changing the break condition to this:
is a poor workaround, not the fix of the root cause, but with exception of exactly 100 uploaded files it worked and contracts were successfully loaded with the patched code.
Describe the bug After 100 or more files are uploaded to BTFS, the command
btfs storage contracts sync renter
stops working.To Reproduce Steps to reproduce the behavior:
btfs storage contracts sync renter
orbtfs storage contracts sync -p renter
Error: context deadline exceeded
-p
parameter was used, all contracts are gone:Expected behavior The command should update status of all renter contracts.
Screenshots N/A
Desktop (please complete the following information):
Additional context My understanding is that pagination of this upstream API is not working:
The above code extract is from
core/commands/storage/contracts/contracts.go
functionGetUpdatedGuardContractsForRenter
. The ListRenterFileInfo API is likely ignoring RequestPageSize and/or RequestPageIndex parameter. Because of this, once the page length is reached, the API instead of returning 100 files on page index 0 and the rest on page index 1 is always returning all files. Because of it, once 100 files are reached, the break conditiondoes not work and the function is stacked in an infinite loop until timeout is reached. Then, because of the timeout, the rest of the process is not executed and no contracts are loaded. In addition, the loop is continuing running in the background even after the command is terminated due to timeout and if the same command is issued multiple times, BTFS daemon is consuming more and more resources and needs to be killed. Changing the break condition to this:
is a poor workaround, not the fix of the root cause, but with exception of exactly 100 uploaded files it worked and contracts were successfully loaded with the patched code.