mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
🐛 Add retry mechanism for internal tmp file handling on s3 backend
This commit is contained in:
parent
f4ae8ea5ac
commit
f1b82e289d
1 changed files with 24 additions and 11 deletions
|
@ -59,6 +59,10 @@
|
||||||
software.amazon.awssdk.services.s3.presigner.model.GetObjectPresignRequest
|
software.amazon.awssdk.services.s3.presigner.model.GetObjectPresignRequest
|
||||||
software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest))
|
software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest))
|
||||||
|
|
||||||
|
(def ^:private max-retries
|
||||||
|
"A maximum number of retries on internal operations"
|
||||||
|
3)
|
||||||
|
|
||||||
(declare put-object)
|
(declare put-object)
|
||||||
(declare get-object-bytes)
|
(declare get-object-bytes)
|
||||||
(declare get-object-data)
|
(declare get-object-data)
|
||||||
|
@ -128,18 +132,27 @@
|
||||||
[backend object]
|
[backend object]
|
||||||
(us/assert! ::backend backend)
|
(us/assert! ::backend backend)
|
||||||
|
|
||||||
(let [result (p/await (get-object-data backend object))]
|
(loop [result (get-object-data backend object)
|
||||||
(if (ex/exception? result)
|
retryn 0]
|
||||||
(cond
|
|
||||||
(ex/instance? NoSuchKeyException result)
|
|
||||||
(ex/raise :type :not-found
|
|
||||||
:code :object-not-found
|
|
||||||
:hint "s3 object not found"
|
|
||||||
:cause result)
|
|
||||||
:else
|
|
||||||
(throw result))
|
|
||||||
|
|
||||||
result)))
|
(let [result (p/await result)]
|
||||||
|
(if (ex/exception? result)
|
||||||
|
(cond
|
||||||
|
(ex/instance? NoSuchKeyException result)
|
||||||
|
(ex/raise :type :not-found
|
||||||
|
:code :object-not-found
|
||||||
|
:hint "s3 object not found"
|
||||||
|
:cause result)
|
||||||
|
|
||||||
|
(and (ex/instance? java.nio.file.FileAlreadyExistsException result)
|
||||||
|
(< retryn max-retries))
|
||||||
|
(recur (get-object-data backend object)
|
||||||
|
(inc retryn))
|
||||||
|
|
||||||
|
:else
|
||||||
|
(throw result))
|
||||||
|
|
||||||
|
result))))
|
||||||
|
|
||||||
(defmethod impl/get-object-bytes :s3
|
(defmethod impl/get-object-bytes :s3
|
||||||
[backend object]
|
[backend object]
|
||||||
|
|
Loading…
Add table
Reference in a new issue