New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: puller rewrite and bug fixes #3437
Changes from 10 commits
c66214a
84b7a37
20cbcdf
6338679
e15ce06
bcc76d4
bd72ec0
488db7b
8a75cc4
987a878
a03b64d
32ac92a
a95ab4f
740c436
081e428
ff7688f
a6a7ca9
0f53bfc
c3fb373
239a691
1061c6c
6abf7a4
a7fe7a9
ae7a090
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ import ( | |
"sync" | ||
"time" | ||
|
||
"github.com/ethersphere/bee/pkg/flipflop" | ||
"github.com/ethersphere/bee/pkg/shed" | ||
"github.com/ethersphere/bee/pkg/storage" | ||
"github.com/ethersphere/bee/pkg/swarm" | ||
|
@@ -44,18 +43,16 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until uint64) | |
|
||
chunkDescriptors := make(chan storage.Descriptor) | ||
|
||
in, out, clean := flipflop.NewFallingEdge(flipFlopBufferDuration, flipFlopWorstCaseDuration) | ||
trigger := make(chan struct{}, 1) | ||
trigger <- struct{}{} | ||
|
||
db.pullTriggersMu.Lock() | ||
if _, ok := db.pullTriggers[bin]; !ok { | ||
db.pullTriggers[bin] = make([]chan<- struct{}, 0) | ||
} | ||
db.pullTriggers[bin] = append(db.pullTriggers[bin], in) | ||
db.pullTriggers[bin] = append(db.pullTriggers[bin], trigger) | ||
db.pullTriggersMu.Unlock() | ||
|
||
// send signal for the initial iteration | ||
in <- struct{}{} | ||
|
||
stopChan := make(chan struct{}) | ||
var stopChanOnce sync.Once | ||
|
||
|
@@ -65,7 +62,6 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until uint64) | |
|
||
db.subscriptionsWG.Add(1) | ||
go func() { | ||
defer clean() | ||
defer db.subscriptionsWG.Done() | ||
defer db.metrics.SubscribePullStop.Inc() | ||
// close the returned store.Descriptor channel at the end to | ||
|
@@ -83,7 +79,7 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until uint64) | |
first := true // first iteration flag for SkipStartFromItem | ||
for { | ||
select { | ||
case <-out: | ||
case <-trigger: | ||
// iterate until: | ||
// - last index Item is reached | ||
// - subscription stop is called | ||
|
@@ -171,9 +167,9 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until uint64) | |
defer db.pullTriggersMu.Unlock() | ||
|
||
for i, t := range db.pullTriggers[bin] { | ||
if t == in { | ||
if t == trigger { | ||
db.pullTriggers[bin] = append(db.pullTriggers[bin][:i], db.pullTriggers[bin][i+1:]...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The channel can be closed here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that will trigger the above select, it should be okay like this |
||
break | ||
return | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These triggers would be fired on put operations. As it is buffered the Put operation would block on the pullIndex iteration completion everytime. How would this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see line 208, subscription_pull.go.
It is a select with a default, so no blocks