discovery+routing: cancel dependent jobs if parent validation fails
Previously, we would always allow dependent jobs to be processed, regardless of the result of its parent job's validation. This isn't correct, as a parent job contains actions necessary to successfully process a dependent job. A prime example of this can be found within the AuthenticatedGossiper, where an incoming channel announcement and update are both processed, but if the channel announcement job fails to complete, then the gossiper is unable to properly validate the update. This commit aims to address this by preventing the dependent jobs to run.
This commit is contained in:
4 files changed
+142
-86
No files matched your search
@@ -12,6 +12,8 @@ import (
|
||||
// TestValidationBarrierSemaphore checks basic properties of the validation
|
||||
// barrier's semaphore wrt. enqueuing/dequeuing.
|
||||
func TestValidationBarrierSemaphore(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const (
|
||||
numTasks = 8
|
||||
numPendingTasks = 8
|
||||
@@ -59,6 +61,8 @@ func TestValidationBarrierSemaphore(t *testing.T) {
|
||||
// TestValidationBarrierQuit checks that pending validation tasks will return an
|
||||
// error from WaitForDependants if the barrier's quit signal is canceled.
|
||||
func TestValidationBarrierQuit(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const (
|
||||
numTasks = 8
|
||||
timeout = 50 * time.Millisecond
|
||||
@@ -113,9 +117,14 @@ func TestValidationBarrierQuit(t *testing.T) {
|
||||
// with the correct error.
|
||||
for i := 0; i < numTasks; i++ {
|
||||
switch {
|
||||
// First half, signal completion and task semaphore
|
||||
// Signal completion for the first half of tasks, but only allow
|
||||
// dependents to be processed as well for the second quarter.
|
||||
case i < numTasks/4:
|
||||
barrier.SignalDependants(anns[i], false)
|
||||
barrier.CompleteJob()
|
||||
|
||||
case i < numTasks/2:
|
||||
barrier.SignalDependants(anns[i])
|
||||
barrier.SignalDependants(anns[i], true)
|
||||
barrier.CompleteJob()
|
||||
|
||||
// At midpoint, quit the validation barrier.
|
||||
@@ -132,7 +141,10 @@ func TestValidationBarrierQuit(t *testing.T) {
|
||||
|
||||
switch {
|
||||
// First half should return without failure.
|
||||
case i < numTasks/2 && err != nil:
|
||||
case i < numTasks/4 && err != routing.ErrParentValidationFailed:
|
||||
t.Fatalf("unexpected failure while waiting: %v", err)
|
||||
|
||||
case i >= numTasks/4 && i < numTasks/2 && err != nil:
|
||||
t.Fatalf("unexpected failure while waiting: %v", err)
|
||||
|
||||
// Last half should return the shutdown error.
|
||||
|
||||
Reference in new issue
Block a user