Skip to content
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

[wip] mdbx: future 13 version, master build #139

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0a6a526
save
AskAlexSharov Mar 21, 2024
3c83997
save
AskAlexSharov Mar 22, 2024
0070e75
save
AskAlexSharov Mar 22, 2024
7e2a48b
save
AskAlexSharov Mar 24, 2024
5d7b4e6
save
AskAlexSharov Mar 24, 2024
f7e0a7c
save
AskAlexSharov Mar 24, 2024
8dff620
save
AskAlexSharov Mar 24, 2024
2a7d4b3
save
AskAlexSharov Mar 25, 2024
6284309
save
AskAlexSharov Apr 15, 2024
ea46fce
save
AskAlexSharov Apr 15, 2024
4db72cc
save
AskAlexSharov Apr 15, 2024
0d9682a
save
AskAlexSharov Apr 15, 2024
91f082f
save
AskAlexSharov Apr 15, 2024
59924a9
save
AskAlexSharov Apr 15, 2024
301a4ce
save
AskAlexSharov Apr 15, 2024
2389f79
save
AskAlexSharov Apr 27, 2024
ae1afd5
save
AskAlexSharov Apr 27, 2024
a2a657e
save
AskAlexSharov Apr 27, 2024
02a0bc4
save
AskAlexSharov Apr 27, 2024
114ad31
Merge branch 'master' into e35_mdbx_v0_13
AskAlexSharov May 23, 2024
3dd65a8
save
AskAlexSharov May 23, 2024
c926483
save
AskAlexSharov May 26, 2024
c37a1cd
save
AskAlexSharov May 26, 2024
a15bd8c
save
AskAlexSharov Jun 9, 2024
0814248
save
AskAlexSharov Jun 9, 2024
7e75c2a
save
AskAlexSharov Jun 9, 2024
bab6021
save
AskAlexSharov Jun 9, 2024
c05978c
save
AskAlexSharov Jun 9, 2024
409bb2c
save
AskAlexSharov Jun 9, 2024
cd00096
save
AskAlexSharov Jun 12, 2024
2d7f0e7
save
AskAlexSharov Jun 12, 2024
c901b9c
Merge branch 'master' into e35_mdbx_v0_13
AskAlexSharov Jun 15, 2024
a98daa6
save
AskAlexSharov Jun 15, 2024
e9a1e3f
save
AskAlexSharov Jun 16, 2024
087145f
save
AskAlexSharov Jun 16, 2024
31a3bca
Merge branch 'master' into e35_mdbx_v0_13
AskAlexSharov Jun 18, 2024
146cff2
save
AskAlexSharov Jun 19, 2024
ddeb6a8
save
AskAlexSharov Jun 19, 2024
9fc3dad
save
AskAlexSharov Jun 21, 2024
affb875
Merge branch 'master' into e35_mdbx_v0_13
AskAlexSharov Jun 28, 2024
8158a71
merge main
AskAlexSharov Jun 28, 2024
11cda1b
save
AskAlexSharov Jul 12, 2024
0a5edde
save
AskAlexSharov Jul 12, 2024
a014903
save
AskAlexSharov Jul 12, 2024
0740b51
save
AskAlexSharov Jul 20, 2024
9e6df54
save
AskAlexSharov Aug 3, 2024
09542ff
save
AskAlexSharov Aug 5, 2024
a070643
save
AskAlexSharov Aug 16, 2024
77c9c03
Merge branch 'master' into e35_mdbx_v0_13
AskAlexSharov Aug 16, 2024
bd1cbb1
save
AskAlexSharov Oct 18, 2024
90477b7
save
AskAlexSharov Nov 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ jobs:
with:
go-version: '1.20'

- run: go env
- run: go test -p 1 ./mdbx
- run: go test -p 1 ./exp/mdbxpool
- run: go test ./mdbx
- run: go test ./exp/mdbxpool
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MASTER_COMMIT=`git rev-parse --short origin/master`

deps: lintci-deps
go get -d ./...
go get ./...

all: deps

Expand All @@ -20,7 +20,7 @@ lint:

lintci-deps:
rm -f ./build/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.59.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.61.0

clean:
cd mdbxdist && make clean
Expand All @@ -29,5 +29,7 @@ tools: clean
cd mdbxdist && MDBX_BUILD_TIMESTAMP=unknown CFLAGS="${CFLAGS} -Wno-unknown-warning-option -Wno-enum-int-mismatch -Wno-strict-prototypes -Wno-unused-but-set-variable" make tools

cp:
cd ../libmdbx && make dist && cp -R dist/* ./../mdbx-go/mdbxdist/
pwd
cp mdbxdist/mdbx.h mdbx/
cp mdbxdist/mdbx.c mdbx/
3 changes: 3 additions & 0 deletions mdbx/Notes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This package contains only mdbx.h and mdbx.c - to minimize go build time/size.
But full version of libmdbx (produced by it's `make dist` command) is in `./../mdbxdist/`. License is also there.

2 changes: 2 additions & 0 deletions mdbx/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const (
Set = C.MDBX_SET // The specified key.
SetKey = C.MDBX_SET_KEY // Get key and data at the specified key.
SetRange = C.MDBX_SET_RANGE // The first key no less than the specified key.

LesserThan = C.MDBX_TO_KEY_LESSER_THAN
)

// The MDB_MULTIPLE and MDB_RESERVE flags are special and do not fit the
Expand Down
42 changes: 30 additions & 12 deletions mdbx/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ const (
EnvDefaults = C.MDBX_ENV_DEFAULTS
LifoReclaim = C.MDBX_LIFORECLAIM
//FixedMap = C.MDBX_FIXEDMAP // Danger zone. Map memory at a fixed address.
NoSubdir = C.MDBX_NOSUBDIR // Argument to Open is a file, not a directory.
Accede = C.MDBX_ACCEDE
Coalesce = C.MDBX_COALESCE
Readonly = C.MDBX_RDONLY // Used in several functions to denote an object as readonly.
WriteMap = C.MDBX_WRITEMAP // Use a writable memory map.
NoMetaSync = C.MDBX_NOMETASYNC // Don't fsync metapage after commit.
UtterlyNoSync = C.MDBX_UTTERLY_NOSYNC
SafeNoSync = C.MDBX_SAFE_NOSYNC
Durable = C.MDBX_SYNC_DURABLE
NoTLS = C.MDBX_NOTLS // Danger zone. When unset reader locktable slots are tied to their thread.
NoSubdir = C.MDBX_NOSUBDIR // Argument to Open is a file, not a directory.
Accede = C.MDBX_ACCEDE
Coalesce = C.MDBX_COALESCE
Readonly = C.MDBX_RDONLY // Used in several functions to denote an object as readonly.
WriteMap = C.MDBX_WRITEMAP // Use a writable memory map.
NoMetaSync = C.MDBX_NOMETASYNC // Don't fsync metapage after commit.
UtterlyNoSync = C.MDBX_UTTERLY_NOSYNC
SafeNoSync = C.MDBX_SAFE_NOSYNC
Durable = C.MDBX_SYNC_DURABLE
NoTLS = C.MDBX_NOTLS // Danger zone. When unset reader locktable slots are tied to their thread.
NoStickyThreads = C.MDBX_NOSTICKYTHREADS // Danger zone. Like MDBX_NOTLS. But also allow move RwTx between threads. Still require to call Begin/Rollback in stame thread.
//NoLock = C.MDBX_NOLOCK // Danger zone. MDBX does not use any locks.
NoReadahead = C.MDBX_NORDAHEAD // Disable readahead. Requires OS support.
NoMemInit = C.MDBX_NOMEMINIT // Disable MDBX memory initialization.
Expand Down Expand Up @@ -106,6 +107,7 @@ const (
OptSpillMinDenominator = C.MDBX_opt_spill_min_denominator
OptSpillParent4ChildDenominator = C.MDBX_opt_spill_parent4child_denominator
OptMergeThreshold16dot16Percent = C.MDBX_opt_merge_threshold_16dot16_percent
OptPreferWafInsteadofBalance = C.MDBX_opt_prefer_waf_insteadof_balance
)

var (
Expand Down Expand Up @@ -365,7 +367,24 @@ func (env *Env) Info(txn *Txn) (*EnvInfo, error) {
if ret != success {
return nil, operrno("mdbx_env_info", ret)
}
info := EnvInfo{
return castEnvInfo(_info), nil
}

func PreOpenSnapInfo(path string) (*EnvInfo, error) {
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))

var _info C.MDBX_envinfo
var bytes C.size_t = C.size_t(unsafe.Sizeof(_info))
ret := C.mdbx_preopen_snapinfo(cpath, &_info, bytes)
if ret != success {
return nil, operrno("mdbx_preopen_snapinfo", ret)
}
return castEnvInfo(_info), nil
}

func castEnvInfo(_info C.MDBX_envinfo) *EnvInfo {
return &EnvInfo{
MapSize: int64(_info.mi_mapsize),
Geo: EnvInfoGeo{
Lower: uint64(_info.mi_geo.lower),
Expand Down Expand Up @@ -402,7 +421,6 @@ func (env *Env) Info(txn *Txn) (*EnvInfo, error) {
SinceReaderCheck: toDuration(_info.mi_since_reader_check_seconds16dot16),
Flags: uint(_info.mi_mode),
}
return &info, nil
}

// Sync flushes buffers to disk. If force is true a synchronous flush occurs
Expand Down
25 changes: 25 additions & 0 deletions mdbx/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,31 @@ func TestEnv_Open(t *testing.T) {
}
}

func TestEnv_PreOpen(t *testing.T) {
env, err1 := NewEnv()
if err1 != nil {
t.Error(err1)
return
}
defer env.Close()

// open an environment at a temporary path.
path := t.TempDir()
err := env.Open(path, 0, 0664)
if err != nil {
t.Errorf("open: %s", err)
}
env.Close()

_info, err := PreOpenSnapInfo(path)
if err != nil {
panic(err)
}

fmt.Printf("%#v\n", _info)

}

/*
func TestEnv_FD(t *testing.T) {
if runtime.GOOS == "windows" {
Expand Down
4 changes: 2 additions & 2 deletions mdbx/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ var CorruptErrorMessage = CorruptErrorHardwareRecommendations + " " + CorruptErr

func (e Errno) Error() string {
if e == Corrupted {
return "MDBX_FATAL: " + CorruptErrorMessage
return fmt.Sprintf("MDBX_FATAL(%d): ", int(e)) + CorruptErrorMessage
}
if e == Panic {
return "MDBX_PANIC: " + CorruptErrorMessage
return fmt.Sprintf("MDBX_PANIC(%d): ", int(e)) + CorruptErrorMessage
}
return C.GoString(C.mdbx_strerror(C.int(e)))
}
Expand Down
Loading
Loading