Describe the bug
Running simple small code
package main
import (
"crypto/rand"
"log/slog"
"os"
"path"
"github.com/dgraph-io/badger/v4"
"github.com/google/uuid"
)
func main() {
location := path.Join(os.TempDir(), uuid.NewString())
bo := badger.DefaultOptions(location).
WithValueThreshold(1 << 10). // 1KB
WithValueLogFileSize(4 << 20) // 4MB
if db, err := badger.Open(bo); err != nil {
slog.Error("DB OPEN", slog.Any("error", err))
return
} else {
for range 1000 {
if err := db.Update(func(txn *badger.Txn) error {
key := make([]byte, 200)
val := make([]byte, 2<<10) // 2KB
for range 1024 {
rand.Read(key)
rand.Read(val)
if err := txn.Set(key, val); err != nil {
return err
}
}
return nil
}); err != nil {
slog.Error("update error", slog.Any("error", err))
return
}
}
if err := db.Close(); err != nil {
slog.Error("DB CLOSE", slog.Any("error", err))
}
}
}
ended up with error on i386 mode
badger 2026/05/25 18:45:27 ERROR: writeRequests: while opening file: /tmp/59afbd42-0850-4222-b5f9-5a185fcbfd81/000348.vlog err: cannot allocate memory
while mmapping /tmp/59afbd42-0850-4222-b5f9-5a185fcbfd81/000348.vlog with size: 8388608
The same code on x86_64 run just fine on
To Reproduce
Steps to reproduce the behavior:
$ git clone git@github.com:softkot/badger-allocate-386-issue.git && cd badger-allocate-386-issue
$ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go run .
$ CGO_ENABLED=0 GOOS=linux GOARCH=386 go run .
--------> ERR HERE <------------
Environment
$ uname -m -v -s -r
Linux 6.5.0-17-generic #17~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 16 14:32:32 UTC 2 x86_64
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy
$ go version
go version go1.26.2 linux/amd64
$ free -h
total used free shared buff/cache available
Mem: 29Gi 3,5Gi 595Mi 77Mi 25Gi 25Gi
Swap: 15Gi 3,5Gi 12Gi
Describe the bug
Running simple small code
ended up with error on i386 mode
The same code on x86_64 run just fine on
To Reproduce
Steps to reproduce the behavior:
Environment