mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
only allow one fragment to load at a time
This commit is contained in:
parent
df1886f8a2
commit
2b1801167e
1 changed files with 11 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ package index
|
|||
|
||||
import (
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
|
|
@ -16,6 +17,12 @@ import (
|
|||
"sort"
|
||||
)
|
||||
|
||||
var globalLock *sync.Mutex
|
||||
|
||||
func init() {
|
||||
globalLock = new(sync.Mutex)
|
||||
}
|
||||
|
||||
type Pair struct {
|
||||
Key, Count uint64
|
||||
}
|
||||
|
|
@ -382,6 +389,7 @@ func (self *Brand) Persist() error {
|
|||
|
||||
func (self *Brand) Load(requestChan chan Command, f *Fragment) {
|
||||
log.Println("Brand Load")
|
||||
time.Sleep(time.Duration(rand.Intn(32)) * time.Second) //trying to avoid mass cassandra hit
|
||||
r, err := util.Open(self.getFileName())
|
||||
if err != nil {
|
||||
log.Println("NO Brand Init File:", self.getFileName())
|
||||
|
|
@ -393,7 +401,9 @@ func (self *Brand) Load(requestChan chan Command, f *Fragment) {
|
|||
return
|
||||
//log.Println("Bad mojo")
|
||||
}
|
||||
time.Sleep(time.Duration(rand.Intn(15)) * time.Second) //trying to avoid mass cassandra hit
|
||||
globalLock.Lock()
|
||||
defer globalLock.Unlock()
|
||||
// probaly need to get a etcd lock too someday
|
||||
for _, k := range keys {
|
||||
request := NewLoadRequest(k)
|
||||
requestChan <- request
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue