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

Add mdbx_drop cli tool #1553

Merged
merged 5 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ db-tools: mdbx
cp ethdb/mdbx/dist/mdbx_dump $(GOBIN)
cp ethdb/mdbx/dist/mdbx_load $(GOBIN)
cp ethdb/mdbx/dist/mdbx_stat $(GOBIN)
cp ethdb/mdbx/dist/mdbx_drop $(GOBIN)
@echo "Run \"$(GOBIN)/lmdb_stat -h\" to get info about lmdb file."

mdbx:
Expand All @@ -98,7 +99,6 @@ mdbx:
&& make clean && make config.h \
&& echo '#define MDBX_DEBUG 0' >> config.h \
&& echo '#define MDBX_FORCE_ASSERTIONS 0' >> config.h \
&& echo '#define MDBX_ENABLE_MADVISE 0' >> config.h \
&& echo '#define MDBX_TXN_CHECKOWNER 1' >> config.h \
&& echo '#define MDBX_ENV_CHECKPID 1' >> config.h \
&& echo '#define MDBX_DISABLE_PAGECHECKS 0' >> config.h \
Expand Down
29 changes: 14 additions & 15 deletions ethdb/kv_mdbx.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,20 @@ func (opts MdbxOpts) Open() (KV, error) {
// 1/8 is good for transactions with a lot of modifications - to reduce invalidation size.
// But TG app now using Batch and etl.Collectors to avoid writing to DB frequently changing data.
// It means most of our writes are: APPEND or "single UPSERT per key during transaction"
if err = env.SetOption(mdbx.OptSpillMinDenominator, 8); err != nil {
return nil, err
}
//if err = env.SetOption(mdbx.OptSpillMaxDenominator, 0); err != nil {
// return nil, err
//}
if err = env.SetOption(mdbx.OptTxnDpInitial, 4*1024); err != nil {
return nil, err
}
if err = env.SetOption(mdbx.OptDpReverseLimit, 4*1024); err != nil {
return nil, err
}
if err = env.SetOption(mdbx.OptTxnDpLimit, opts.dirtyListMaxPages); err != nil {
return nil, err
}
/*
if err = env.SetOption(mdbx.OptSpillMinDenominator, 8); err != nil {
return nil, err
}
if err = env.SetOption(mdbx.OptTxnDpInitial, 4*1024); err != nil {
return nil, err
}
if err = env.SetOption(mdbx.OptDpReverseLimit, 4*1024); err != nil {
return nil, err
}
if err = env.SetOption(mdbx.OptTxnDpLimit, opts.dirtyListMaxPages); err != nil {
return nil, err
}
*/
}

db := &MdbxKV{
Expand Down
1 change: 1 addition & 0 deletions ethdb/mdbx/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ mdbx_copy
mdbx_dump
mdbx_load
mdbx_stat
mdbx_drop
4 changes: 3 additions & 1 deletion ethdb/mdbx/dist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ if(MDBX_BUILD_TOOLS)
set(WINGETOPT_SRC "")
endif()

foreach(TOOL mdbx_chk mdbx_copy mdbx_stat mdbx_dump mdbx_load)
foreach(TOOL mdbx_chk mdbx_copy mdbx_stat mdbx_dump mdbx_load mdbx_drop)
add_executable(${TOOL} mdbx.h ${MDBX_SOURCE_DIR}/${TOOL}.c ${WINGETOPT_SRC})
if(MDBX_C_STANDARD)
set_target_properties(${TOOL} PROPERTIES
Expand Down Expand Up @@ -704,6 +704,7 @@ if(MDBX_BUILD_TOOLS)
mdbx_copy
mdbx_dump
mdbx_load
mdbx_drop
RUNTIME
DESTINATION ${MDBX_TOOLS_INSTALL_DESTINATION}
COMPONENT runtime)
Expand All @@ -718,6 +719,7 @@ if(MDBX_BUILD_TOOLS)
"${MDBX_SOURCE_DIR}/man1/mdbx_copy.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_dump.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_load.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_drop.1"
DESTINATION ${MDBX_MAN_INSTALL_DESTINATION}
COMPONENT doc)
endif()
Expand Down
14 changes: 12 additions & 2 deletions ethdb/mdbx/dist/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ChangeLog
---------

## v0.9.4 (in development) scheduled at 2021-02-23
## v0.9.4 (in development) scheduled at 2021-03-18

TODO:

Expand All @@ -13,7 +13,8 @@ TODO:

Acknowledgements:

- [Alex Sharov](https://github.com/AskAlexSharov) for [mdbx-go](https://github.com/torquem-ch/mdbx-go).
- [Alex Sharov](https://github.com/AskAlexSharov) for [mdbx-go](https://github.com/torquem-ch/mdbx-go) and for bug reporting.
- [Artem Vorotnikov](https://github.com/vorot93) for bug reporting.

New features:

Expand All @@ -22,10 +23,19 @@ New features:
The `MDBX_DISABLE_PAGECHECKS=1` provides a performance boost of about 10% in CRUD scenarios,
and conjointly with the `MDBX_ENV_CHECKPID=0` and `MDBX_TXN_CHECKOWNER=0` options can yield
up to 30% more performance compared to LMDB.
- Using float point (exponential quantized) representation for internal 16-bit values
of grow step and shrink threshold when huge ones (https://github.com/erthink/libmdbx/issues/166).
To minimize the impact on compatibility, only the odd values inside the upper half
of the range (i.e. 32769..65533) are used for the new representation.
- Added the `mdbx_drop` similar to LMDB command-line tool to purge or delete (sub)database(s).

Fixes:

- Fixed performance regression due non-optimal C11 atomics usage (https://github.com/erthink/libmdbx/issues/160).
- Fixed "reincarnation" of subDB after it deletion (https://github.com/erthink/libmdbx/issues/168).
- Fixed (disallowing) implicit subDB deletion via operations on `@MAIN`'s DBI-handle.
- Fixed a crash of `mdbx_env_info_ex()` in case of a call for a non-open environment (https://github.com/erthink/libmdbx/issues/171).
- Fixed the selecting/adjustment values inside `mdbx_env_set_geometry()` for implicit out-of-range cases (https://github.com/erthink/libmdbx/issues/170).


## v0.9.3 at 2021-02-02
Expand Down
4 changes: 2 additions & 2 deletions ethdb/mdbx/dist/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ SO_SUFFIX := $(shell $(uname2sosuffix))

HEADERS := mdbx.h mdbx.h++
LIBRARIES := libmdbx.a libmdbx.$(SO_SUFFIX)
TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk
MANPAGES := mdbx_stat.1 mdbx_copy.1 mdbx_dump.1 mdbx_load.1 mdbx_chk.1
TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk mdbx_drop
MANPAGES := mdbx_stat.1 mdbx_copy.1 mdbx_dump.1 mdbx_load.1 mdbx_chk.1 mdbx_drop.1

.PHONY: mdbx all install clean

Expand Down
2 changes: 1 addition & 1 deletion ethdb/mdbx/dist/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.3.12
0.9.3.40
1 change: 1 addition & 0 deletions ethdb/mdbx/dist/man1/mdbx_chk.1
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ if no quiet mode was requested.
.BR mdbx_copy (1),
.BR mdbx_dump (1),
.BR mdbx_load (1)
.BR mdbx_drop (1)
.SH AUTHOR
Leonid Yuriev <https://github.com/erthink>
1 change: 1 addition & 0 deletions ethdb/mdbx/dist/man1/mdbx_copy.1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ free during copying cannot be reused until the copy is done.
.BR mdbx_chk (1),
.BR mdbx_stat (1),
.BR mdbx_load (1)
.BR mdbx_drop (1)
.SH AUTHOR
Howard Chu of Symas Corporation <http://www.symas.com>,
Leonid Yuriev <https://github.com/erthink>
48 changes: 48 additions & 0 deletions ethdb/mdbx/dist/man1/mdbx_drop.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.\" Copyright 2021 Leonid Yuriev <leo@yuriev.ru>.
.\" Copyright 2014-2021 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDBX_DROP 1 "2021-02-02" "MDBX 0.9.3"
.SH NAME
mdbx_drop \- MDBX database delete tool
.SH SYNOPSIS
.B mdbx_drop
[\c
.BR \-V ]
[\c
.BR \-d ]
[\c
.BI \-s \ subdb\fR]
[\c
.BR \-n ]
.BR \ dbpath
.SH DESCRIPTION
The
.B mdbx_drop
utility empties or deletes a database in the specified
environment.
.SH OPTIONS
.TP
.BR \-V
Write the library version number to the standard output, and exit.
.TP
.BR \-d
Delete the specified database, don't just empty it.
.TP
.BR \-s \ subdb
Operate on a specific subdatabase. If no database is specified, only the main database is dropped.
.TP
.BR \-n
Dump an MDBX database which does not use subdirectories.
This is legacy option. For now MDBX handles this automatically.

.SH DIAGNOSTICS
Exit status is zero if no errors occur.
Errors result in a non-zero exit status and
a diagnostic message being written to standard error.
.SH "SEE ALSO"
.BR mdbx_load (1),
.BR mdbx_copy (1),
.BR mdbx_chk (1),
.BR mdbx_stat (1)
.SH AUTHOR
Howard Chu of Symas Corporation <http://www.symas.com>
1 change: 1 addition & 0 deletions ethdb/mdbx/dist/man1/mdbx_dump.1
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ utility to load the database using the correct comparison functions.
.BR mdbx_copy (1),
.BR mdbx_chk (1),
.BR mdbx_stat (1)
.BR mdbx_drop (1)
.SH AUTHOR
Howard Chu of Symas Corporation <http://www.symas.com>,
Leonid Yuriev <https://github.com/erthink>
1 change: 1 addition & 0 deletions ethdb/mdbx/dist/man1/mdbx_load.1
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ a diagnostic message being written to standard error.
.BR mdbx_chk (1),
.BR mdbx_stat (1),
.BR mdbx_copy (1)
.BR mdbx_drop (1)
.SH AUTHOR
Howard Chu of Symas Corporation <http://www.symas.com>,
Leonid Yuriev <https://github.com/erthink>
1 change: 1 addition & 0 deletions ethdb/mdbx/dist/man1/mdbx_stat.1
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ a diagnostic message being written to standard error.
.BR mdbx_copy (1),
.BR mdbx_dump (1),
.BR mdbx_load (1)
.BR mdbx_drop (1)
.SH AUTHOR
Howard Chu of Symas Corporation <http://www.symas.com>,
Leonid Yuriev <https://github.com/erthink>
Loading