PDFCLOUD-5382 Add retries and logging#2
Conversation
|
Please rebase to eliminate the duplicate commits. |
- Implemented exponential backoff with jitter for retryable errors. - Added `max_retries` parameter to clients for configurable retry limits. - Enhanced error handling for transport, timeout, and server-side errors. - Updated unit tests to validate retry behavior, including success after retries and error propagation after retry limits. - Covered edge cases, such as negative retry limits and proper delay calculations. Assisted-by: Codex
- Introduced structured logging for request and response details, including retry attempts, delays, payloads, and errors. - Integrated sanitized logging for sensitive header information. - Improved debugging of request execution and retry behavior for better traceability. - Updated exception handling to include detailed log outputs. Assisted-by: Codex
741c9a0 to
1b70258
Compare
Done. Technically there aren't duplicate commits because there isn't a Y-shaped branch pattern with the same commits on each side of the Y-fork. But I did it anyway, because GitHub doesn't clean up the commit list unless something happens. |
|
So I had Codex review Codex, and: I don't believe pdfRest ever returns a Similar deal with See item the 1st. |
|
In the time this PR has been waiting, the pdfRest container actually started to return a 429. I don't think anything's sending Retry-After unless it's from a gateway put in front of the server. Thanks for having Codex review Codex. I had Codex review its work, and it didn't find as much, but I gave Codex these concerns to chew on. |
- Implemented logic to track and rewind file streams between retries. - Enhanced retry mechanism to respect `Retry-After` headers with both seconds and HTTP-date formats. - Improved handling of non-seekable streams, logging errors and aborting retries gracefully. - Updated tests to cover stream behavior during retries, including seekable and non-seekable streams. - Refactored retry logic to include customizable pre-attempt hooks and delay adjustments based on responses. - Handle 408, 429, and 499 retries. Assisted-by: Codex
9803552 to
9186eb7
Compare
- To prevent complexity, the file stream and its position belong to the caller. - Any failure that happens after the connection starts might have read from the stream. After that, doing the retry is the responsibility of the caller. - Removed complex stream tracking logic in favor of a simplified `_has_stream_uploads` attribute. - Introduced exceptions `PdfRestConnectTimeoutError` and `PdfRestPoolTimeoutError` for granularity in timeout scenarios, including new cases for retry logic. - Updated `translate_httpx_error` method for finer mapping between `httpx` exceptions and retry behavior. - Enhanced `_contains_open_stream` method for better stream detection in nested structures. - Updated tests for refined handling of retries and no-retry cases, including transport errors, timeouts, and server errors. Assisted-by: Codex
- Introduced `send_request_once` and `run_with_retry` for consistent request execution and retry handling. - Implemented retries for `create_from_paths` in both sync and async clients, covering 429, transport, and timeout errors. - Added concurrency control using semaphores for async file info fetches after uploads. - Updated tests to validate retry behavior, including various error scenarios and proper retry counts. Assisted-by: Codex
aba2d2d to
b670bec
Compare
|
I took another look at this and:
|
PDFCLOUD-5382
Summary
Adds configurable, robust retries with exponential backoff and jitter to the pdfRest clients, along with structured, sanitized logging for requests, responses, and retry behavior. Improves error handling and observability, and introduces comprehensive tests covering success-after-retry, limits, and edge cases.
Changes
Add retry logic and backoff mechanism for client requests
max_retries.Add logging to pdfRest clients
PDFREST_LOGto eitherinfoordebug