Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

When second confirmation writing happen error #31

Closed
dreamsxin opened this issue Apr 18, 2018 · 6 comments
Closed

When second confirmation writing happen error #31

dreamsxin opened this issue Apr 18, 2018 · 6 comments
Assignees
Labels

Comments

@dreamsxin
Copy link
Contributor

dreamsxin commented Apr 18, 2018

The first and second write same 100000 items, if second write 1 item will success and then change to 100000 will be success.

mdbx_env_set_mapsize(env, 256 * 1024 * 1024);
mdbx_env_set_maxdbs(env, 256);
rc = mdbx_env_open(env, "./example-db", 0, 0664);
bits.h:1122: NODEPTR: Assertion `NUMKEYS(p) > (unsigned)(i)' failed.
(gdb) bt
#0  0x00007ffff6428428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff642a02a in __GI_abort () at abort.c:89
#2  0x00007ffff6420bd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x7fffec062fbe "NUMKEYS(p) > (unsigned)(i)", file=file@entry=0x7fffec062cee "./storage/libmdbx/bits.h", 
    line=line@entry=1122, function=function@entry=0x7fffec064170 <__PRETTY_FUNCTION__.32848> "NODEPTR") at assert.c:92
#3  0x00007ffff6420c82 in __GI___assert_fail (assertion=assertion@entry=0x7fffec062fbe "NUMKEYS(p) > (unsigned)(i)", file=file@entry=0x7fffec062cee "./storage/libmdbx/bits.h", line=line@entry=1122, 
    function=function@entry=0x7fffec064170 <__PRETTY_FUNCTION__.32848> "NODEPTR") at assert.c:101
#4  0x00007fffec029e5b in NODEPTR (i=0, p=<optimized out>) at ./storage/libmdbx/bits.h:1122
#5  0x00007ffbits.h:1122: NODEPTR: Assertion `NUMKEYS(p) > (unsigned)(i)' failed.fec032f8f in NODEPTR (i=0, p=<optimized out>) at /home/server/work/cphalcon7/ext/storage/libmdbx/mdbx.c:6533
#6  mdbx_cursor_first (mc=mc@entry=0x7fffffff9c20, key=key@entry=0x7fffffff9b50, data=data@entry=0x0) at /home/server/work/cphalcon7/ext/storage/libmdbx/mdbx.c:7026
#7  0x00007fffec0341a5 in mdbx_cursor_get (mc=mc@entry=0x7fffffff9c20, key=key@entry=0x7fffffff9b50, data=data@entry=0x0, op=op@entry=MDBX_FIRST)
    at /home/server/work/cphalcon7/ext/storage/libmdbx/mdbx.c:7228
#8  0x00007fffec031262 in mdbx_page_alloc (num=num@entry=2, mp=mp@entry=0x7fffffff9df0, flags=flags@entry=15, mc=<optimized out>, mc=<optimized out>)
    at /home/server/work/cphalcon7/ext/storage/libmdbx/mdbx.c:2204
#9  0x00007fffec034ae0 in mdbx_page_new (mc=mc@entry=0x7fffffffa0a0, flags=flags@entry=4, num=2, mp=mp@entry=0x7fffffff9e60) at /home/server/work/cphalcon7/ext/storage/libmdbx/mdbx.c:8022
#10 0x00007fffec03506d in mdbx_node_add (mc=mc@entry=0x7fffffffa0a0, indx=0, key=key@entry=0x7fffffffa080, data=<optimized out>, pgno=pgno@entry=0, flags=<optimized out>)
    at /home/server/work/cphalcon7/ext/storage/libmdbx/mdbx.c:8169
#11 0x00007fffec0396c0 in mdbx_cursor_put (mc=mc@entry=0x7fffffffa0a0, key=key@entry=0x7fffffffa080, data=data@entry=0x7fffffffa090, flags=flags@entry=65536)
    at /home/server/work/cphalcon7/ext/storage/libmdbx/mdbx.c:7768
#12 0x00007fffec03bc1d in mdbx_freelist_save (txn=0x555555f5b170) at /home/server/work/cphalcon7/ext/storage/libmdbx/mdbx.c:3614
#13 mdbx_txn_commit (txn=0x555555f5b170) at /home/server/work/cphalcon7/ext/storage/libmdbx/mdbx.c:4194
@erthink
Copy link
Owner

erthink commented Apr 18, 2018

Couldn't reproduce. Please provide a testcase.

@dreamsxin
Copy link
Contributor Author

I use it directly in the PHP extension, and guess is due to different compilation parameters.

@erthink
Copy link
Owner

erthink commented Apr 18, 2018

@dreamsxin, however I should warn you - this could be a bug.

Historically MDBX inherites enough code opacity and bugs from LMDB (
So, be free to fill an issue.

@dreamsxin
Copy link
Contributor Author

If you want to compile PHP extensions, you can try.

Environment:

  • OS: Ubuntu16.04

Step 1:

sudo apt-get install php7.0-dev
git clone -b libmdbx https://github.com/dreamsxin/cphalcon7.git
cd cphalcon7/ext
phpize
./configure --enable-storage-libmdbx=yes
make -j4 && sudo make install

Step 2:
Add extension=phalcon.so to file /etc/php/7.0/cli/php.ini at the end of the file.

Create file test.php code:

<?php

$lmdb = new Phalcon\Storage\Libmdbx('./testdb');
$total = 100000;

$lmdb->begin();
for ($i = 0; $i < $total; $i++) {
	$lmdb->put('key_'.$i, 'value'.$i);
}
$lmdb->commit();

$lmdb->begin();
for ($i = 0; $i < $total; $i++) {
	$lmdb->put('key_'.$i, 'value'.$i);
}
$lmdb->commit();

Step 3:

php test.php

@dreamsxin dreamsxin reopened this Apr 19, 2018
@erthink
Copy link
Owner

erthink commented Apr 24, 2018

Confirmed, this is the BUG.

@dreamsxin
Copy link
Contributor Author

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants