1 As posted to http://www.openldap.org/lists/openldap-devel/200610/msg00027.html
3 This is Sleepycat bug #14908. The provided patch is for 4.2.52. The
4 same bug is present in all versions up to 4.5.20 where it is fixed.
6 -------- Original Message --------
7 Subject: region size bug Re: [BDB-Alpha] Berkeley DB 4.5.8 ALPHA
8 Date: Mon, 10 Jul 2006 13:37:33 -0700
9 From: Howard Chu <hyc@symas.com>
10 To: support@sleepycat.com
12 References: <45A742B5-7DD5-4512-A204-A10FE8FC5DFC@oracle.com>
15 I just ran into this in 4.2.52 but the same calculation occurs in 4.4
18 This computation gives the wrong results when the number of cache
19 regions is greater than the number of gigabytes (which we encounter on
20 Linux using shared memory regions, which are constrained to much smaller
21 than a gigabyte each).
30 /* Figure out how big each cache region is. */
31 reg_size = (roff_t)(dbenv->mp_gbytes / dbenv->mp_ncache) * GIGABYTE;
32 reg_size += ((roff_t)(dbenv->mp_gbytes %
33 dbenv->mp_ncache) * GIGABYTE) / dbenv->mp_ncache;
34 reg_size += dbenv->mp_bytes / dbenv->mp_ncache;
35 *reg_sizep = reg_size;
38 The first reg_size calculation always goes to zero when mp_ncache >
40 This should have been, instead:
41 reg_size = GIGABYTE / dbenv->mp_ncache * dbenv->mp_gbytes;
43 --- mp/mp_region.c.O 2003-06-30 10:20:19.000000000 -0700
44 +++ mp/mp_region.c 2006-10-27 23:25:05.000000000 -0700
46 int htab_buckets, ret;
48 /* Figure out how big each cache region is. */
49 - reg_size = (dbenv->mp_gbytes / dbenv->mp_ncache) * GIGABYTE;
50 - reg_size += ((dbenv->mp_gbytes %
51 - dbenv->mp_ncache) * GIGABYTE) / dbenv->mp_ncache;
52 + reg_size = GIGABYTE / dbenv->mp_ncache * dbenv->mp_gbytes;
53 reg_size += dbenv->mp_bytes / dbenv->mp_ncache;