Skip to content

Commit

Permalink
discovery+graph: track job set dependencies in ValidationBarrier
Browse files Browse the repository at this point in the history
Prior to this commit, it was rare, but possible that proper
validation order was not adhered to when using the ValidationBarrier.
This commit does two things that fix this:
- removes the concept of allow / deny. Having this in place was a
  minor optimization and removing it makes the solution simpler.
- changes the job dependency tracking to track sets of parent jobs
  rather than individual parent jobs.
  • Loading branch information
Crypt-iQ committed Nov 4, 2024
1 parent b163b70 commit 7acf321
Show file tree
Hide file tree
Showing 2 changed files with 292 additions and 120 deletions.
14 changes: 9 additions & 5 deletions discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1470,11 +1470,14 @@ func (d *AuthenticatedGossiper) networkHandler() {
// We'll set up any dependent, and wait until a free
// slot for this job opens up, this allow us to not
// have thousands of goroutines active.
validationBarrier.InitJobDependencies(announcement.msg)
annJobID := validationBarrier.InitJobDependencies(
announcement.msg,
)

d.wg.Add(1)
go d.handleNetworkMessages(
announcement, &announcements, validationBarrier,
announcement, &announcements,
validationBarrier, annJobID,
)

// The trickle timer has ticked, which indicates we should
Expand Down Expand Up @@ -1525,7 +1528,8 @@ func (d *AuthenticatedGossiper) networkHandler() {
//
// NOTE: must be run as a goroutine.
func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,
deDuped *deDupedAnnouncements, vb *graph.ValidationBarrier) {
deDuped *deDupedAnnouncements, vb *graph.ValidationBarrier,
jobID graph.JobID) {

defer d.wg.Done()
defer vb.CompleteJob()
Expand All @@ -1536,7 +1540,7 @@ func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,

// If this message has an existing dependency, then we'll wait until
// that has been fully validated before we proceed.
err := vb.WaitForDependants(nMsg.msg)
err := vb.WaitForParents(jobID, nMsg.msg)
if err != nil {
log.Debugf("Validating network message %s got err: %v",
nMsg.msg.MsgType(), err)
Expand Down Expand Up @@ -1566,7 +1570,7 @@ func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,

// If this message had any dependencies, then we can now signal them to
// continue.
vb.SignalDependants(nMsg.msg, allow)
vb.SignalDependents(nMsg.msg, jobID)

// If the announcement was accepted, then add the emitted announcements
// to our announce batch to be broadcast once the trickle timer ticks
Expand Down
Loading

0 comments on commit 7acf321

Please sign in to comment.