File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -81,13 +81,27 @@ func (me *regularTrackerAnnounceDispatcher) init(client *Client) {
8181 me .logger = client .slogger
8282 me .announceData .Init (torrentTrackerAnnouncerKey .Compare )
8383 me .announceData .SetMinRecord (torrentTrackerAnnouncerKey {})
84+ // This is super pedantic, we're checking distinct root tables are synced with each other. In
85+ // this case there's a trigger in infohashAnnouncing to update all the corresponding infohashes
86+ // in announceData. Anytime announceData is changed, we check it's still up to date with
87+ // infohashAnnouncing.
8488 me .announceData .OnChange (func (old , new g.Option [indexed.Pair [torrentTrackerAnnouncerKey , nextAnnounceInput ]]) {
8589 if ! new .Ok {
8690 return
8791 }
88- panicif .NotEq (
89- new .Value .Right .infohashActive ,
90- g .OptionFromTuple (me .infohashAnnouncing .Get (new .Value .Left .ShortInfohash )).Value .count )
92+ // Due to trigger chains that result in announceData being updated *for unrelated fields*,
93+ // the check occurred prematurely while updating announceData. The fix is to update all
94+ // indexes, then to do triggers. This is massive overkill for this project right now.
95+ actual := new .Value .Right .infohashActive
96+ key := new .Value .Left
97+ expected := g .OptionFromTuple (me .infohashAnnouncing .Get (key .ShortInfohash )).Value .count
98+ if actual != expected {
99+ me .logger .Debug (
100+ "announceData.infohashActive != infohashAnnouncing.count" ,
101+ "key" , key ,
102+ "actual" , actual ,
103+ "expected" , expected )
104+ }
91105 })
92106 me .announceIndex = indexed .NewFullMappedIndex (
93107 & me .announceData ,
You can’t perform that action at this time.
0 commit comments