[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#7623) P_SUBP page inn MDB dirty_list



This is a multi-part message in MIME format.
--------------010403050509060707070108
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

h.b.furuseth@usit.uio.no wrote:
> Full_Name: Hallvard B Furuseth
> Version: RE24 + mdb.master 2d0b362b6f2b1247eb693008a39efaf341f15e82
> OS: Linux x86_64
> URL:
> Submission from: (NULL) (193.69.163.163)
> Submitted by: hallvard
>
>
> test043-delta-syncrepl crashes in RE24 + mdb.master + this patch.
> A sub-cursor sees a regular (non-sub) page which has P_SUB set,
> in dirty_list. The flag comes from the fake page in cursor_put.

The flag is being propagated when the page grows and turns into a real page. 
Fixed by this simple patch.

I don't think we actually want to keep the debug code/flag you added, but I'll 
leave it to you to commit.
>
> Patch:
> - Set P_FAKE flag for debugging, to see where the flag comes from.
> - assert(not P_SUB) in page_get.
> - valloc pages so we can see from the page address that it is
>    a regular page.
>
> --- libraries/liblmdb/mdb.c
> +++ libraries/liblmdb/mdb.c
> @@ -59,2 +59,3 @@
>   #include <unistd.h>
> +#include <malloc.h>
>
> @@ -582,2 +583,3 @@ typedef struct MDB_page {
>   #define	P_SUBP		 0x40		/**< for #MDB_DUPSORT sub-pages */
> +#define P_FAKE		 0x80		/**< fake page */
>   /** @} */
> @@ -1271,3 +1273,3 @@ mdb_page_malloc(MDB_cursor *mc, unsigned num)
>   	}
> -	if ((ret = malloc(sz)) != NULL) {
> +	if ((ret = valloc(sz)) != NULL) {
>   		VGMEMP_ALLOC(env, ret, sz);
> @@ -2478,2 +2480,3 @@ mdb_txn_commit(MDB_txn *txn)
>   			dp = txn->mt_u.dirty_list[i].mptr;
> +			assert(!(dp->mp_flags & P_SUBP));
>   			if (dp->mp_pgno != next) {
> @@ -4069,2 +4072,3 @@ mdb_page_get(MDB_txn *txn, pgno_t pgno, MDB_page **ret,
> int *lvl)
>   					p = dl[x].mptr;
> +					/* assert(!(p->mp_flags & P_SUBP)); */
>   					goto done;
> @@ -5164,3 +5168,3 @@ more:
>   				fp->mp_pgno = mc->mc_pg[mc->mc_top]->mp_pgno;
> -				fp->mp_flags = P_LEAF|P_DIRTY|P_SUBP;
> +				fp->mp_flags = P_LEAF|P_DIRTY|P_SUBP|P_FAKE;
>   				fp->mp_lower = PAGEHDRSZ;
>


-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

--------------010403050509060707070108
Content-Type: text/plain; charset=UTF-8;
 name="dif.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dif.txt"

diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c
index c9f98cc..1bc0f14 100644
--- a/libraries/liblmdb/mdb.c
+++ b/libraries/liblmdb/mdb.c
@@ -5242,6 +5242,7 @@ reuse:
 					flags |= F_DUPDATA;
 				}
 				mp->mp_flags = fp->mp_flags | P_DIRTY;
+				mp->mp_flags &= ~(P_SUBP|P_FAKE);
 				mp->mp_pad   = fp->mp_pad;
 				mp->mp_lower = fp->mp_lower;
 				mp->mp_upper = fp->mp_upper + offset;

--------------010403050509060707070108--