Re-read a delivery before failing it for a missing target
failMissingTarget failed the delivery as the batch had read it, so a delivery a worker sent and let go between the batch read and the ownership check could end failed after a successful attempt. It now reads the row once it owns the delivery and fails it only if the status is still the one the batch read, as processNewTask does. A row that cannot be read is left alone. TestSweepPending_TargetDeleted now checks that the first sweep already queues the healthy delivery and the second does not queue it again. Model: opus-5-5
This commit is contained in:
@@ -342,6 +342,16 @@ func (e *Engine) ExportRecoverRetryingDeliveries(
|
||||
e.recoverRetryingDeliveries(webhookDB, webhookID)
|
||||
}
|
||||
|
||||
// ExportFailMissingTarget exposes failMissingTarget, so a test can hand
|
||||
// it a delivery as a batch read it earlier.
|
||||
func (e *Engine) ExportFailMissingTarget(
|
||||
webhookDB *gorm.DB,
|
||||
webhookID string,
|
||||
d *database.Delivery,
|
||||
) {
|
||||
e.failMissingTarget(webhookDB, webhookID, d)
|
||||
}
|
||||
|
||||
// ExportDeliveryCh returns the delivery channel.
|
||||
func (e *Engine) ExportDeliveryCh() chan Task {
|
||||
return e.deliveryCh
|
||||
|
||||
Reference in New Issue
Block a user