dogbutcat / gclone

fork from https://github.com/donwa/gclone
166 stars 28 forks source link

只在750g上传达到时才切换sa #12

Closed Rhilip closed 1 year ago

Rhilip commented 2 years ago

目前在遇到 ratelimit 的时候就会自动切换sa,但其实ratelimit并不一定达到 750G上传的限制,也有可能是请求过快。 此时再切换sa,反而会因为频繁切换sa被google封project。

https://github.com/dogbutcat/gclone/blob/7f0d26f130d6ce795fd2282498008b02b81f52f9/backend/drive/drive.go#L756-L766

希望能和rclone参照的StopOnUploadLimit功能相结合,增加 rollingOnUploadLimit 选项

// 我不会Go语言,所以以下仅作示例
if (!f.opt.rollingOnUploadLimit && f.opt.ServiceAccountFilePath != "")  {
    f.waitChangeSvc.Lock()
    f.changeSvc(ctx)
    f.waitChangeSvc.Unlock()
    return true, err
}
if gerr.Errors[0].Message == "User rate limit exceeded." {
    if (f.opt.rollingOnUploadLimit && f.opt.ServiceAccountFilePath != "") {
        f.waitChangeSvc.Lock()
        f.changeSvc(ctx)
        f.waitChangeSvc.Unlock()
        return true, err
    }
    if (f.opt.StopOnUploadLimit) {  
        fs.Errorf(f, "Received upload limit error: %v", err)
        return false, fserrors.FatalError(err)
    }
}
jidanyunmian commented 2 years ago

请问楼主,封project是整个sa都封掉了吗

Rhilip commented 2 years ago

请问楼主,封project是整个sa都封掉了吗

被封的project下所有sa无法使用,可以删了被封的project重来。

jidanyunmian commented 2 years ago

感谢回复,现在团队盘 to 团队盘 不走服务器的话 gclone每天只有2T的配额了?

dogbutcat commented 2 years ago

谢谢您的建议。

对于您的建议我想问下您是在什么情况下会遇到过请求过快?

官方文档对于错误的描述如下

A rateLimitExceeded error indicates the project's rate limit has been reached. This limit varies depending on the type of requests. Following is the JSON representation of this error

A userRateLimitExceeded error indicates the per-user limit has been reached. This might be a limit from the Google API Console or a limit from the Drive backend. Following is the JSON representation of this error

这两种场景都是需要切换的。

我猜想您如果指的是api请求之间不要太过于频繁, 那么rclone提供了相应的api用于适当延长时间:

--drive-pacer-min-sleep
Minimum time to sleep between API calls.

Properties:

Config: pacer_min_sleep
Env Var: RCLONE_DRIVE_PACER_MIN_SLEEP
Type: Duration
Default: 100ms
dogbutcat commented 2 years ago

对于750G的upload limit.

我在备份3T的共享盘的过程中发现某个文件的owner上传到达limit之后 即使使用没有满额的sa读取对应owner的文件也会出现速率报错 也可能就是您描述的这种. 所以才加了rolling的功能. 所以我判断这个750G的limit是针对的本地上传. 远程备份可能与读写存在一定关联.