Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Feb 16, 2023
1 parent f498bd2 commit 8deee58
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions memdb_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package db
import (
"bytes"
"context"
"fmt"
"runtime/debug"
"time"

"github.com/google/btree"
)
Expand Down Expand Up @@ -45,6 +48,7 @@ func newMemDBIteratorMtxChoice(db *MemDB, start []byte, end []byte, reverse bool
if useMtx {
db.mtx.RLock()
}
callingStack := debug.Stack()
go func() {
if useMtx {
defer db.mtx.RUnlock()
Expand All @@ -64,11 +68,15 @@ func newMemDBIteratorMtxChoice(db *MemDB, start []byte, end []byte, reverse bool
if abortLessThan != nil && bytes.Compare(item.key, abortLessThan) == -1 {
return false
}
select {
case <-ctx.Done():
return false
case ch <- &item:
return true
for {
select {
case <-ctx.Done():
return false
case ch <- &item:
return true
case <-time.After(10 * time.Second):
fmt.Printf("TMDBTEST stuck channel called by %s\n", callingStack)
}
}
}
switch {
Expand Down

0 comments on commit 8deee58

Please sign in to comment.