Skip to content

Commit 2ec8293

Browse files
authored
Update report update condition to use report ID
When multiple identical reports are submitted, there can be a race condition where a report is committed for that node during the time the second report is being processed and they are both trying to be set as the latest report, resulting in a duplicate report being stored. This causes any subsequent report submissions to fail for that node. This fixes the problem by using the latest-report-id calculated when the function is called, using its timestamp to decide if this report is in fact the latest report. Fixes #16.
1 parent 6177c86 commit 2ec8293

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/puppetlabs/puppetdb/scf/storage.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@
14941494
;; from the case where the incoming report needs partition(s) made for it.
14951495
(try
14961496
(jdbc/update! "resource_events" {:latest false} ["latest = true and report_id = ?" latest-report-id])
1497-
(jdbc/update! "reports" {:latest false} ["latest = true and certname = ?" certname])
1497+
(jdbc/update! "reports" {:latest false} ["latest = true and id = ?" latest-report-id])
14981498
(catch java.sql.BatchUpdateException e
14991499
;; undefined table -- inheritance partitions, or declarative partitions w/ no children
15001500
;; check constraint violation -- declarative partitions when row does not match child partitions

0 commit comments

Comments
 (0)