Comments (13)
The source:
package main
import (
"fmt"
"math/rand"
"os"
"time"
"github.com/dgraph-io/badger/badger"
)
const numOfKeys = 1e5
func init() {
rand.Seed(time.Now().UnixNano())
}
func randomString(length int) string {
candidates := []byte("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
buffer := make([]byte, length)
for i := 0; i < length; i++ {
buffer[i] = candidates[rand.Intn(len(candidates))]
}
return string(buffer)
}
func main() {
kv := map[string]string{}
for i := 0; i < numOfKeys; i++ {
kv[randomString(128)] = randomString(1024)
}
// open KV store
path := "/tmp/badger-store"
os.RemoveAll(path)
os.MkdirAll(path, 0755)
opt := badger.DefaultOptions
opt.Dir = path
opt.Verbose = true
store, err := badger.NewKV(&opt)
if err != nil {
fmt.Printf("unable to open KV store [%s]: %v\n", path, err)
os.Exit(1)
}
defer store.Close()
writeCount := 0
for i := 0; i < 100; i++ {
for key, value := range kv {
store.Set([]byte(key), []byte(value))
writeCount++
fmt.Printf("\r%8d ... ", writeCount)
}
}
}
from badger.
More details about the test:
- official golang docker image (https://hub.docker.com/_/golang/), it happened to native Mac golang env as well
- Latest badger codes (commit 22225f8)
- Need to be patient - it happens between 1.1M and 1.2M writes and make take up to 30 minutes, I guess it can be faster if choose to use different key/value size
from badger.
Hey @hangxie, thanks for reporting. Looks like some race condition. We will investigate that.
from badger.
Thanks Szymon, I managed to make it happens more frequently by changing:
numOfKeys
in test.go to 1000 so we have enough garbages in value log- set
opt.ValueLogFileSize
to 16M so we have enough value log files - hack
runGCInLoop
function ingithub.com/dgraph-io/badger/badger/value.go
to change the timer from 10 minutes to 1 minute so have GC happens faster than default
The assertion failure happened in the first or the second GC with above changes, which takes only 1 or 2 minutes, this may make test easier.
from badger.
@hangxie : @szymonm submitted a fix for this. If you still see this issue, feel free to reopen.
from badger.
It runs longer, but still happens:
rewrite called
2017/05/30 18:20:04 len(requests): 2
github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/y.AssertTruef
/go/src/github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/y/error.go:70
github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/badger.(*valueLog).writeToKV
/go/src/github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/badger/value.go:320
github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/badger.(*valueLog).rewrite
/go/src/github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/badger/value.go:278
github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/badger.(*valueLog).doRunGC
/go/src/github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/badger/value.go:873
github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/badger.(*valueLog).runGCInLoop
/go/src/github.com/hangxie/playground/badger/vendor/github.com/dgraph-io/badger/badger/value.go:750
runtime.goexit
/usr/local/Cellar/go/1.8.3/libexec/src/runtime/asm_amd64.s:2197
Here are version info from glide.lock:
- name: github.com/AndreasBriese/bbloom
version: 0320de81a58b973b5187098f4815608711c70f3b
- name: github.com/bkaradzic/go-lz4
version: 74ddf82598bc4745b965729e9c6a463bedd33049
- name: github.com/dgraph-io/badger
version: d752fb0f333b8b26584283f75dfb743d4995c331
from badger.
I don't seem to have the permission to re-open the issue @manishrjain
from badger.
@szymonm : The PR you implemented didn't fix this bug yet.
from badger.
@hangxie I can't reproduce it. I've been running it for almost 2 hours now. Are you still using these parameters:
- numOfKeys in test.go to 1000 so we have enough garbages in value log
- set opt.ValueLogFileSize to 16M so we have enough value log files
- hack runGCInLoop function in github.com/dgraph-io/badger/badger/value.go to change the timer from 10 minutes to 1 minute so have GC happens faster than default
?
from badger.
Can you check with this fix: #52 ?
from badger.
I doubt #52 will help.
I'm running this as well on my machine with the fix submitted y'day. So far no crashes. Will keep it running for another half an hour or so.
from badger.
17:10:46 /tmp/t
$ go build . && ./t /tmp/t
Seeking at value pointer: {Fid:0 Len:0 Offset:0}
42423 ... Skipping GC on fid: 0
84479 ... Skipping GC on fid: 0
126485 ... Skipping GC on fid: 1
169522 ... =====> REWRITING VLOG 1
rewrite called
169560 ... REWRITE DONE
212328 ... =====> REWRITING VLOG 2
rewrite called
212370 ... REWRITE DONE
255062 ... =====> REWRITING VLOG 3
rewrite called
255101 ... REWRITE DONE
298241 ... =====> REWRITING VLOG 4
rewrite called
298277 ... REWRITE DONE
341782 ... =====> REWRITING VLOG 9
rewrite called
341829 ... REWRITE DONE
384666 ... =====> REWRITING VLOG 13
rewrite called
384692 ... REWRITE DONE
427870 ... =====> REWRITING VLOG 0
rewrite called
427920 ... REWRITE DONE
470565 ... =====> REWRITING VLOG 15
rewrite called
470609 ... REWRITE DONE
513364 ... =====> REWRITING VLOG 6
rewrite called
513398 ... REWRITE DONE
556308 ... =====> REWRITING VLOG 32
rewrite called
556357 ... REWRITE DONE
598780 ... =====> REWRITING VLOG 16
rewrite called
598803 ... REWRITE DONE
640728 ... =====> REWRITING VLOG 11
rewrite called
640770 ... REWRITE DONE
682748 ... =====> REWRITING VLOG 8
rewrite called
682794 ... REWRITE DONE
725276 ... =====> REWRITING VLOG 5
rewrite called
725304 ... REWRITE DONE
767355 ... =====> REWRITING VLOG 23
rewrite called
767398 ... REWRITE DONE
810417 ... =====> REWRITING VLOG 25
rewrite called
810461 ... REWRITE DONE
853520 ... =====> REWRITING VLOG 37
rewrite called
853563 ... REWRITE DONE
896515 ... =====> REWRITING VLOG 17
rewrite called
896562 ... REWRITE DONE
939253 ... =====> REWRITING VLOG 20
rewrite called
939294 ... REWRITE DONE
981541 ... =====> REWRITING VLOG 49
rewrite called
981598 ... REWRITE DONE
1024444 ... =====> REWRITING VLOG 12
rewrite called
1024504 ... REWRITE DONE
1067141 ... =====> REWRITING VLOG 7
rewrite called
1067187 ... REWRITE DONE
1110058 ... =====> REWRITING VLOG 34
1110059 ... rewrite called
1110101 ... REWRITE DONE
1151993 ... =====> REWRITING VLOG 14
rewrite called
1152036 ... REWRITE DONE
1194915 ... =====> REWRITING VLOG 50
rewrite called
1194960 ... REWRITE DONE
1238260 ... =====> REWRITING VLOG 22
rewrite called
1238304 ... REWRITE DONE
1280722 ... =====> REWRITING VLOG 65
rewrite called
1280773 ... REWRITE DONE
1323470 ... =====> REWRITING VLOG 21
rewrite called
1323512 ... REWRITE DONE
1366213 ... =====> REWRITING VLOG 47
rewrite called
1366266 ... REWRITE DONE
1409565 ... =====> REWRITING VLOG 10
rewrite called
1409614 ... REWRITE DONE
1453143 ... =====> REWRITING VLOG 68
rewrite called
1453197 ... REWRITE DONE
1496420 ... =====> REWRITING VLOG 38
rewrite called
1496465 ... REWRITE DONE
1540466 ... =====> REWRITING VLOG 60
rewrite called
1540514 ... REWRITE DONE
1585606 ... =====> REWRITING VLOG 72
rewrite called
1585633 ... REWRITE DONE
1632314 ... =====> REWRITING VLOG 43
rewrite called
1632334 ... REWRITE DONE
1675628 ... =====> REWRITING VLOG 18
rewrite called
1675680 ... REWRITE DONE
1719182 ... =====> REWRITING VLOG 94
rewrite called
1719232 ... REWRITE DONE
1763578 ... =====> REWRITING VLOG 39
rewrite called
1763606 ... REWRITE DONE
1808006 ... =====> REWRITING VLOG 51
rewrite called
1808045 ... REWRITE DONE
1851705 ... =====> REWRITING VLOG 28
rewrite called
1851735 ... REWRITE DONE
1895826 ... =====> REWRITING VLOG 54
rewrite called
1895868 ... REWRITE DONE
1939470 ... =====> REWRITING VLOG 61
rewrite called
1939507 ... REWRITE DONE
1983388 ... =====> REWRITING VLOG 97
rewrite called
1983445 ... REWRITE DONE
2026832 ... =====> REWRITING VLOG 91
rewrite called
2026882 ... REWRITE DONE
2071334 ... =====> REWRITING VLOG 81
rewrite called
2071377 ... REWRITE DONE
2116188 ... =====> REWRITING VLOG 63
rewrite called
2116250 ... REWRITE DONE
2129406 ... ^C
Ran it for close to an hour. Didn't see this crash. Can you check that you have the latest changes, @hangxie ?
from badger.
Also, the main.go that I ran:
import (
"fmt"
"math/rand"
"os"
"time"
"github.com/dgraph-io/badger/badger"
)
const numOfKeys = 1e5
func init() {
rand.Seed(time.Now().UnixNano())
}
func randomString(length int) string {
candidates := []byte("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
buffer := make([]byte, length)
for i := 0; i < length; i++ {
buffer[i] = candidates[rand.Intn(len(candidates))]
}
return string(buffer)
}
func main() {
kv := map[string]string{}
for i := 0; i < numOfKeys; i++ {
kv[randomString(128)] = randomString(1024)
}
// open KV store
path := "/tmp/badger-store"
os.RemoveAll(path)
os.MkdirAll(path, 0755)
opt := badger.DefaultOptions
opt.Dir = path
opt.Verbose = true
opt.ValueGCRunInterval = 10 * time.Second
opt.ValueLogFileSize = 16 << 20
store, err := badger.NewKV(&opt)
if err != nil {
fmt.Printf("unable to open KV store [%s]: %v\n", path, err)
os.Exit(1)
}
defer store.Close()
writeCount := 0
for i := 0; i < 100; i++ {
for key, value := range kv {
store.Set([]byte(key), []byte(value))
writeCount++
fmt.Printf("\r%8d ... ", writeCount)
}
}
}
from badger.
Related Issues (20)
- [BUG]: Panic from a lot of DELs and SETs with very large keys
- [BUG]: when compression is none block cache will cache the table
- [QUESTION]: Batch write is partially committed when badger crashes
- [QUESTION]: Search keys by regular expressions HOT 1
- [BUG]: arm64 inconsistencies HOT 1
- [QUESTION]: Is Badger rsync friendly during db in use ? HOT 3
- How to achieve multiple process sharing and open a db
- [BUG]: compilation fails with `GOOS=aix` (Unix) HOT 1
- Memory crash
- [BUG]: RunValueGC HOT 1
- [FEATURE]: Storing values larger than 2 GB HOT 2
- [BUG]: Panic, help!
- [FEATURE]: <TTL Event>
- update ristretto HOT 2
- [BUG]: db.Backup maybe see the `partial write` in one transaction
- [QUESTION]: Can transactions be seen out-of-order within a single Go application?
- loop run backup, out of memory
- [FEATURE]: Allow holding back specific timestamps
- [BUG]: serializable behavior is broken HOT 5
- [BUG]: Corrupt and lost data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from badger.