Skip to content

Commit

Permalink
Merge pull request #3852 from rbrw/pdb-5633-more-defensive-command-er…
Browse files Browse the repository at this point in the history
…ror-handling

(PDB-5633) Handle nil producer timestamp and sql states during errors
  • Loading branch information
austb authored Aug 7, 2023
2 parents 8b680f7 + b7c692c commit eba7916
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/puppetlabs/puppetdb/command.clj
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@
received-time (str (time/to-long received-time))
duration (str (in-millis (interval start-time (now))))
command-name (command-names command-kw)
producer-utc-s (-> producer-ts time/to-timestamp .getTime)
producer-utc-s (or (some-> producer-ts time/to-timestamp .getTime)
"nil")
summary (str id "-" received-time "-" producer-utc-s)
hash-prefix (if hash
(let [hs (if (bytes? hash)
Expand Down Expand Up @@ -528,11 +529,11 @@
;; also assuming that all commands don't vary their behavior
;; across retries sufficiently for that to matter either.
;; This was originally introduced to handle
;; program_limit_exceeded errors caused by attemptps to insert
;; program_limit_exceeded errors caused by attempts to insert
;; resource titles that were too big to fit in a postgres
;; index.
;; cf. https://www.postgresql.org/docs/11/errcodes-appendix.html
(when (str/starts-with? (.getSQLState ex) "54")
(when (some-> ex .getSQLState (str/starts-with? "54"))
(throw (fatality ex)))
(throw ex)))))

Expand Down

0 comments on commit eba7916

Please sign in to comment.