Commit Graph

168 Commits

Author SHA1 Message Date
Howard Chu
9474c1a0b6 ITS#7635 fix read txn potential data race 2013-07-01 13:41:23 -07:00
Howard Chu
3347a02905 Fix uninit warnings, lseek usage 2013-06-30 07:40:02 -07:00
Hallvard Furuseth
7f67383552 Fix alloc/free issues.
Page leak, mdb_page_alloc(). On error, don't shorten me_pghead.
Memleak, mdb_ovpage_free(). Free page or keep it in dirty_list.
Bad MIDL, mdb_midl_need(). Fix midl[-1] (allocated size).
2013-06-26 18:02:52 +02:00
Hallvard Furuseth
12c558fe13 Factor out some vars, simplify. 2013-06-26 18:02:48 +02:00
Hallvard Furuseth
b7ce06f5c5 Makefile/user-macro comments. 2013-06-26 18:02:26 +02:00
Hallvard Furuseth
26a25df5fc Tweak I/O, fix last commit. 2013-06-26 18:02:17 +02:00
Hallvard Furuseth
d6d2638acc Improve MDB error handling, drop seek calls.
Catch I/O errors. Do nothing between OS call failure and ErrCode().
Do not use errno after non-OS-errors like write() >= 0, which could
give a failure return of success (errno 0) or some irrelevant error
code.  Drop seek calls, use pwrite/pread/Windows OVERLAPPED offset.
2013-06-22 23:15:10 +02:00
Hallvard Furuseth
a5701cf2fe Fix Windows I/O.
Don't put a 64-bit filesize in a 32-bit int before shifting
down.  Always pass &sizehi to SetFilePointer->maxsize, so
sizelo not is treated a signed distance.  Hide unused vars
when _WIN32.  Reinitialize OVERLAPPED before reuse.
2013-06-22 23:01:30 +02:00
Hallvard Furuseth
3d4ba01e8b Catch more MDB errors. DPRINTF in mdb_env_reset0. 2013-06-22 22:17:41 +02:00
Hallvard Furuseth
51ff20a4d6 Tweak MIDLs, catch errors.
Grow midls earlier in order to catch errors earlier.  Use
mdb_midl_need() instead of mdb_midl_grow(), then mdb_midl_xappend()
needs no error checks. Factor out mdb_midl_append_range().
2013-06-22 22:10:43 +02:00
Hallvard Furuseth
6b200e3beb Factor out MDB variables/expressions, cleanup.
mdb_page_malloc(): Take a txn arg instead of a cursor.
2013-06-22 12:30:04 +02:00
Hallvard Furuseth
9e6ef6c88f Rearrange MDB dirty page code.
Split out mdb_dpage_free(), mdb_page_flush() and clean up.
2013-06-22 11:56:04 +02:00
Hallvard Furuseth
c6f9323b3d Simplify mdb_page_alloc().
Merge if() branches. Restore retry=500 when MDB_PARANOID, for clarity.
2013-06-20 07:41:35 +02:00
Hallvard Furuseth
4a9ee2cb72 ITS#7620: Keep empty IDLs. Tweak mdb_page_alloc().
MDB_env.me_pghead: Don't free it when empty. mdb_ovpage_free()
needs it, but cannot allocate it.
mdb_midl_alloc(): Fill in length=0.
mdb_page_alloc(): Also Skip freeDB if txnid<3, instead of <4,
and consistently DPRINTF consumed IDLs.
2013-06-20 07:41:35 +02:00
Howard Chu
1d94ea5b55 ITS#7623 Clear P_SUBP on conversion from fake page 2013-06-17 22:26:11 +02:00
Hallvard Furuseth
60086c1bc7 ITS#7515 Nested MDB txns: Inherit txn flags.
Committing a nested txn lost the MDB_TXN_DIRTY flag
in the parent, unless the child had set it too.
2013-06-13 08:58:25 +02:00
Hallvard Furuseth
7030ad16e2 Clean up mdb_page_touch(), mdb_page_copy().
When copying, round up/down to aligned sizes. Skip the unused portion,
this was not done when touching a page dirty in the parent txn.
No other change in behavior.

Simplify mdb_page_touch(), including: Drop test m3==mc, the condition
is caught below. Don't "modify" the parent's pgno into the same pgno,
when a nested txn copies a parent's page into its freelist.
2013-06-13 08:58:24 +02:00
Hallvard Furuseth
79844bd446 ITS#7594 Fix MDB cursor tracking with subDBs.
The tracking code should not change the current cursor.
It did when that was a C_SUB cursor, which should not be
checked against the tracked cursors but their xcursors.

However, do not bother to skip the tracking code for the
current cursor when it would not change that cursor anyway.
2013-06-13 08:58:24 +02:00
Hallvard Furuseth
2bacf6e59e ITS#7594 Invalidate a dropped MDB DB's cursors. 2013-06-13 08:58:24 +02:00
Hallvard Furuseth
62e4c4f9d0 Don't #define _GNU_SOURCE if already defined. 2013-06-13 08:58:24 +02:00
Hallvard Furuseth
c37a11a424 More for ITS#7620 Fix mdb_ovpage_free().
Do not binary-search dirty_list, it is unsorted when MDB_WRITEMAP.
Catch errors. In nested txns, put the page in mt_free_pgs after
all since pages dirty in a parent txn would add complexities.
2013-06-13 08:25:25 +02:00
Howard Chu
2d0b362b6f Partial revert c2cac4588a
MDB_NEXT was fine before, duh.
2013-06-12 08:41:32 -07:00
Hallvard Furuseth
99427aa7de Drop me_pgfree, add mdb_freelist_save().
Split up saving me_pghead, to make me_pgfree unneeded. Also mf_pghead
is now a midl. Needed after e7f6767ea8
("Return fresh overflow pages to current pghead").
Tweak MDB_DEBUG freelist output, make it ascending.
2013-06-12 17:20:42 +02:00
Howard Chu
c2cac4588a Fix CURSOR_NEXT/PREV on emptied DB 2013-06-11 17:13:08 -07:00
Howard Chu
bcb67dd22f Make sure mdb_stat() gets valid data 2013-06-08 14:10:08 -07:00
Howard Chu
e7f6767ea8 Return fresh overflow pages to current pghead
And remove them from the current dirty list.
2013-06-06 16:44:02 -07:00
Howard Chu
aff123ba11 ITS#7594 more for subDB cursor fix 2013-06-05 16:13:43 -07:00
Howard Chu
3b623d66e1 ITS#7594 better fix
Update the subDB cursor, don't invalidate it
2013-06-05 15:23:54 -07:00
Howard Chu
65faa5ed7e tweak mdb_copy, trap signals 2013-05-30 15:56:30 -07:00
Howard Chu
d29b9600e6 Windows portability fixes for prev commit 2013-05-30 15:33:59 -07:00
Howard Chu
f207c50b15 Add warning about interrupting copy 2013-05-30 13:13:33 -07:00
Howard Chu
ad573fe125 Fix prev commit 2013-05-30 13:09:28 -07:00
Howard Chu
c68e5ae9be Add mdb_env_copyfd()
Allow writing backup to an already opened file handle, for piping
to tar/gzip/ssh/whatever.
2013-05-30 13:06:12 -07:00
Howard Chu
4b49291653 Add _M_IX86 macro for MSVC 2013-05-25 10:16:55 -07:00
Howard Chu
e31c7d3b31 ITS#7594 De-init other subcursors in page_touch 2013-05-23 12:17:21 -07:00
Hallvard Furuseth
92fe958805 Drop unused liblmdb MIDL-range support. 2013-05-21 23:58:57 +02:00
Hallvard Furuseth
feaeab0c04 Factor out mdb_find_oldest,mdb_dlist_free,dirty_list.
Do not rescan reader table (mdb_find_oldest) after "goto again".
Skip clearing dirty_list[nonzero].mid in mdb_dlist_free(); it
was not done in mdb_reset0() anyway.
2013-05-21 23:55:13 +02:00
Hallvard Furuseth
5ea1cd8f6d mdb_stat cleanup.
Exit with success when there was no failure.
Do not use data containing NUL as a DB name (which is a C string).
2013-05-21 23:48:27 +02:00
Hallvard Furuseth
a1b16ce5f0 ITS#7598 Tweak MDB_<NEXT/PREV>_NODUP,fix mdb_stat.
MDB_NEXT_NODUP, MDB_PREV_NODUP: Allow for non-MDB_DUPSORT databases.
No mdb.c code changes needed.

mdb_stat.c: Use MDB_NEXT_NODUP, to avoid a crash with a DUPSORT mainDB.
2013-05-21 22:44:51 +02:00
Hallvard Furuseth
1b6d7ee7e1 ITS#7598 mdb_dbi_open(named DB): Check mainDB flags.
Reject attempts to open named databases if the main
database has flag MDB_DUPSORT or MDB_INTEGERKEY.

DUPSORT would require an xcursor for the DB, INTEGERKEY
would expect the DB name to be a binary integer.
2013-05-21 19:04:52 +02:00
Hallvard Furuseth
a2ce25482a ITS#7515 Fix nested txn touch of subpage/ovpage.
mdb_page_touch(): Don't touch a subpage, replacing with non-subpage.
mdb_cursor_put(): Don't overwrite ancestor txn's dirty overflow page.
2013-05-20 23:12:52 +02:00
Hallvard Furuseth
5bdf2aae6e Tweak mdb_page_malloc(),mdb_page_get() semantics.
mdb_page_malloc(): Add "number of pages" parameter.
mdb_page_get(): Add output param for how page was found.
Do not set return params on error.
mdb_cursor_put(): Catch mdb_page_get() error.

Prepares for next commit, no change in caller behavior other
than on mdb_page_get error.
2013-05-20 23:12:26 +02:00
Hallvard Furuseth
2eb50b1d2e More ITS#7589 followup: OVPAGES() -> mp_pages. 2013-05-19 19:08:07 +02:00
Hallvard Furuseth
e4ce404992 More ITS#7589: Fix prev commit.
mp_pages gives #pages in the ovpage. OVPAGES() no longer does.
2013-05-19 18:38:13 +02:00
Hallvard Furuseth
0cdd9dffdd ITS#7589 mdb_cursor_put(): Update ovpage nodesize.
Update the nodesize when overwriting an overflow page.
As before, do not attempt to shrink the page.
2013-05-17 19:31:17 +02:00
Howard Chu
833cd905b7 Include <netinet/in.h> for Solaris 8
Needed for <resolv.h>, which is needed for BYTE_ORDER.
2013-05-15 11:50:40 -07:00
Howard Chu
7233bc295b Fix mdb_page_split - nested split
If updating a page's separator triggers a split in its parent,
we may have missed adjusting the parent's cursor position.
2013-05-14 16:57:50 -07:00
Howard Chu
1105aa35ba Doxygen cleanup 2013-05-13 12:36:47 -07:00
Howard Chu
9ebd5992c9 Fix 66c839f029
Forgot #include <errno.h>
2013-05-10 05:56:16 -07:00
Howard Chu
66c839f029 Refactor mdb_midl_append, add mdb_midl_grow() 2013-05-09 17:27:29 -07:00