Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: dm/appengine/deps/walk_graph.go

Issue 2344893010: Fix walk graph to recurse correctly. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | dm/appengine/deps/walk_graph_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package deps 5 package deps
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "math" 9 "math"
10 "sort" 10 "sort"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 logging.Fields{ek: err, "aid": a id}.Errorf(g, "error loading executions") 287 logging.Fields{ek: err, "aid": a id}.Errorf(g, "error loading executions")
288 } else { 288 } else {
289 dst.Partial.Executions = false 289 dst.Partial.Executions = false
290 } 290 }
291 return err 291 return err
292 } 292 }
293 } 293 }
294 294
295 writeFwd := g.req.Include.FwdDeps 295 writeFwd := g.req.Include.FwdDeps
296 walkFwd := (g.req.Mode.Direction == dm.WalkGraphReq_Mode _BOTH || 296 walkFwd := (g.req.Mode.Direction == dm.WalkGraphReq_Mode _BOTH ||
297 » » » » g.req.Mode.Direction == dm.WalkGraphReq_Mode_FOR WARDS) 297 » » » » g.req.Mode.Direction == dm.WalkGraphReq_Mode_FOR WARDS) && send != nil
298 loadFwd := writeFwd || walkFwd 298 loadFwd := writeFwd || walkFwd
299 299
300 if loadFwd { 300 if loadFwd {
301 isAuthed := g.req.Auth != nil && g.req.Auth.Id.A ttemptID().Equals(aid) 301 isAuthed := g.req.Auth != nil && g.req.Auth.Id.A ttemptID().Equals(aid)
302 subSend := func(aid *dm.Attempt_ID) error { 302 subSend := func(aid *dm.Attempt_ID) error {
303 return send(aid, isAuthed) 303 return send(aid, isAuthed)
304 } 304 }
305 if writeFwd { 305 if writeFwd {
306 dst.FwdDeps = dm.NewAttemptList(nil) 306 dst.FwdDeps = dm.NewAttemptList(nil)
307 } 307 }
308 ch <- func() error { 308 ch <- func() error {
309 err := g.loadEdges(subSend, "FwdDep", ak ey, dst.FwdDeps, walkFwd) 309 err := g.loadEdges(subSend, "FwdDep", ak ey, dst.FwdDeps, walkFwd)
310 if err == nil && dst.Partial != nil { 310 if err == nil && dst.Partial != nil {
311 dst.Partial.FwdDeps = false 311 dst.Partial.FwdDeps = false
312 } else if err != nil { 312 } else if err != nil {
313 logging.Fields{"aid": aid, ek: e rr}.Errorf(g, "while loading FwdDeps") 313 logging.Fields{"aid": aid, ek: e rr}.Errorf(g, "while loading FwdDeps")
314 } 314 }
315 return err 315 return err
316 } 316 }
317 } 317 }
318 318
319 writeBack := g.req.Include.BackDeps 319 writeBack := g.req.Include.BackDeps
320 walkBack := (g.req.Mode.Direction == dm.WalkGraphReq_Mod e_BOTH || 320 walkBack := (g.req.Mode.Direction == dm.WalkGraphReq_Mod e_BOTH ||
321 » » » » g.req.Mode.Direction == dm.WalkGraphReq_Mode_BAC KWARDS) 321 » » » » g.req.Mode.Direction == dm.WalkGraphReq_Mode_BAC KWARDS) && send != nil
322 loadBack := writeBack || walkBack 322 loadBack := writeBack || walkBack
323 323
324 if loadBack { 324 if loadBack {
325 if writeBack { 325 if writeBack {
326 dst.BackDeps = dm.NewAttemptList(nil) 326 dst.BackDeps = dm.NewAttemptList(nil)
327 } 327 }
328 subSend := func(aid *dm.Attempt_ID) error { 328 subSend := func(aid *dm.Attempt_ID) error {
329 return send(aid, false) 329 return send(aid, false)
330 } 330 }
331 bdg := &model.BackDepGroup{Dependee: atmpt.ID} 331 bdg := &model.BackDepGroup{Dependee: atmpt.ID}
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 434
435 // nodeChan recieves attempt nodes to process. If it recieves the 435 // nodeChan recieves attempt nodes to process. If it recieves the
436 // `finishedJob` sentinel node, that indicates that an outstanding worke r is 436 // `finishedJob` sentinel node, that indicates that an outstanding worke r is
437 // finished. 437 // finished.
438 nodeChan := make(chan *node, numWorkers) 438 nodeChan := make(chan *node, numWorkers)
439 defer close(nodeChan) 439 defer close(nodeChan)
440 440
441 g := graphWalker{Context: c, req: req} 441 g := graphWalker{Context: c, req: req}
442 442
443 sendNodeAuthed := func(depth int64) func(*dm.Attempt_ID, bool) error { 443 sendNodeAuthed := func(depth int64) func(*dm.Attempt_ID, bool) error {
444 if req.Limit.MaxDepth != -1 && depth > req.Limit.MaxDepth {
445 return nil
446 }
444 return func(aid *dm.Attempt_ID, isAuthed bool) error { 447 return func(aid *dm.Attempt_ID, isAuthed bool) error {
445 select { 448 select {
446 case nodeChan <- &node{aid: aid, depth: depth, canSeeAtt emptResult: isAuthed}: 449 case nodeChan <- &node{aid: aid, depth: depth, canSeeAtt emptResult: isAuthed}:
447 return nil 450 return nil
448 case <-c.Done(): 451 case <-c.Done():
449 return c.Err() 452 return c.Err()
450 } 453 }
451 } 454 }
452 } 455 }
453 456
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 }} 536 }}
534 if req.Include.Attempt.Result { 537 if req.Include.Attempt.Result {
535 atmpt.Partial.Result = dm.Attempt_Partia l_NOT_LOADED 538 atmpt.Partial.Result = dm.Attempt_Partia l_NOT_LOADED
536 } 539 }
537 540
538 atmpt.NormalizePartial() // in case they're all false 541 atmpt.NormalizePartial() // in case they're all false
539 if req.Include.Attempt.Ids { 542 if req.Include.Attempt.Ids {
540 atmpt.Id = n.aid 543 atmpt.Id = n.aid
541 } 544 }
542 qst.Attempts[n.aid.Id] = atmpt 545 qst.Attempts[n.aid.Id] = atmpt
543 » » » » if req.Limit.MaxDepth == -1 || n.depth < req.Lim it.MaxDepth { 546 » » » » if req.Limit.MaxDepth == -1 || n.depth <= req.Li mit.MaxDepth {
544 addJob(g.attemptLoader(n.aid, n.canSeeAt temptResult, atmpt, 547 addJob(g.attemptLoader(n.aid, n.canSeeAt temptResult, atmpt,
545 sendNodeAuthed(n.depth+1))) 548 sendNodeAuthed(n.depth+1)))
546 } 549 }
547 } 550 }
548 // otherwise, we've dealt with this attempt before, so i gnore it. 551 // otherwise, we've dealt with this attempt before, so i gnore it.
549 } 552 }
550 } 553 }
551 554
552 if c.Err() != nil { 555 if c.Err() != nil {
553 rsp.HadMore = true 556 rsp.HadMore = true
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 func (d *deps) WalkGraph(c context.Context, req *dm.WalkGraphReq) (rsp *dm.Graph Data, err error) { 594 func (d *deps) WalkGraph(c context.Context, req *dm.WalkGraphReq) (rsp *dm.Graph Data, err error) {
592 if req.Auth != nil { 595 if req.Auth != nil {
593 logging.Fields{"execution": req.Auth.Id}.Debugf(c, "on behalf of ") 596 logging.Fields{"execution": req.Auth.Id}.Debugf(c, "on behalf of ")
594 } else { 597 } else {
595 if err = canRead(c); err != nil { 598 if err = canRead(c); err != nil {
596 return 599 return
597 } 600 }
598 } 601 }
599 return doGraphWalk(c, req) 602 return doGraphWalk(c, req)
600 } 603 }
OLDNEW
« no previous file with comments | « no previous file | dm/appengine/deps/walk_graph_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698