acssz / guide

0 stars 1 forks source link

Lark 文档导出任务失败缺少重试策略 #2

Open rabbull opened 3 weeks ago

rabbull commented 3 weeks ago

1 中对请求 Lark Open API 的函数都增加了重试,然而并没有完整的覆盖所有的失败情况:

如果一个文档的导出任务成功创建了,但是 Lark [执行这个任务的时候失败了,那么用来查询导出任务结果的接口 将会返回一个错误码。此时代码wait_task 函数会抛出一个 LarkOpenApiError 异常。重复查询这个任务的结果也会再次抛出异常,因为 Lark 不会自动重试失败的任务。当前的重试策略是对任何抛出了 LarkOpenApiError 异常的调用都进行指数退行重试。

这里有两个问题:

  1. 文档导出任务最终失败的情况下抛出 LarkOpenApiError 异常合理吗?是不是应该用其他类型的异常?
  2. 对于最终失败的情况,需要重新创建新的文档导出任务,对于异步过程来说这个才是有效的重试。
rabbull commented 3 weeks ago

@yoctocell 这个是考核任务的延续,不着急,只是先记在这里,等你有时间了瞅一眼吧~

yoctocell commented 4 days ago

我查看了近几周在文档导出时出现过的异常,有多数是因网络方面(即requests.exceptions.ConnectionError)的问题而引起的,这种情况也应该进行重试。

- requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
https://github.com/acssz/guide/actions/runs/11736460161/job/32695745473
https://github.com/acssz/guide/actions/runs/11839953335/job/32992637589
https://github.com/acssz/guide/actions/runs/11818067988/job/32924810771
https://github.com/acssz/guide/actions/runs/11811026313/job/32903966101
https://github.com/acssz/guide/actions/runs/11803187579/job/32880589730

- requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
https://github.com/acssz/guide/actions/runs/11728811698/job/32673074541
https://github.com/acssz/guide/actions/runs/11468539183/job/31913873310
https://github.com/acssz/guide/actions/runs/11448645047/job/31852616506
https://github.com/acssz/guide/actions/runs/11424335328/job/31784541468
https://github.com/acssz/guide/actions/runs/11927789588/job/33243734228
https://github.com/acssz/guide/actions/runs/11905599951/job/33176356905
https://github.com/acssz/guide/actions/runs/11845524454/job/33011186169

- requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(48960 bytes read, 187635 more expected)', IncompleteRead(48960 bytes read, 187635 more expected))
- https://github.com/acssz/guide/actions/runs/11953014819/job/33319999113

- requests.exceptions.SSLError: HTTPSConnectionPool(host='open.feishu.cn', port=443): Max retries exceeded with url: /open-apis/drive/v1/export_tasks/file/VNT8bJUEpo6t63xnVgDlDcF3gyb/download (Caused by SSLError(SSLError(1, '[SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2580)')))
https://github.com/acssz/guide/actions/runs/11878736779/job/33099793398

- LarkOpenApiError: LarkOpenApiError: 1663 internal error
https://github.com/acssz/guide/actions/runs/11531302470/job/32101850747
https://github.com/acssz/guide/actions/runs/11526048753/job/32089506172
https://github.com/acssz/guide/actions/runs/11502159742/job/32016472782
https://github.com/acssz/guide/actions/runs/11399988156/job/31719889336
https://github.com/acssz/guide/actions/runs/11834036606/job/32973918291
https://github.com/acssz/guide/actions/runs/11779309665/job/32807496559

- LarkOpenApiError: LarkOpenApiError: 3 upload_exported_file_failed
https://github.com/acssz/guide/actions/runs/11677947115/job/32516658914

- LarkOpenApiError: LarkOpenApiError: 2200 Internal Error
https://github.com/acssz/guide/actions/runs/11418563406/job/31772154882
https://github.com/acssz/guide/actions/runs/11393790199/job/31702813490
https://github.com/acssz/guide/actions/runs/11393790199/job/31702813490

- json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
https://github.com/acssz/guide/actions/runs/11389679697/job/31689541854
https://github.com/acssz/guide/actions/runs/11389679697/job/31689541854

- LarkOpenApiError: LarkOpenApiError: None None
https://github.com/acssz/guide/actions/runs/11947679781/job/33304028683

Lark API的所有错误码