From: <tho...@us...> - 2013-10-29 14:01:00
|
Revision: 7496 http://bigdata.svn.sourceforge.net/bigdata/?rev=7496&view=rev Author: thompsonbry Date: 2013-10-29 14:00:53 +0000 (Tue, 29 Oct 2013) Log Message: ----------- reduced WARN => INFO for RWStore allocator recycling in postHACommit() Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-10-29 13:58:38 UTC (rev 7495) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-10-29 14:00:53 UTC (rev 7496) @@ -6301,8 +6301,8 @@ } - // if (log.isInfoEnabled()) - log.warn("Released: " + totalFreed + " addresses from " + modCount + " modified Allocators"); + if (log.isInfoEnabled()) + log.info("Released: " + totalFreed + " addresses from " + modCount + " modified Allocators"); if (log.isTraceEnabled()) { log.trace("OLD BITS: " + BytesUtil.toHexString(oldmetabits)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2013-11-13 17:22:41
|
Revision: 7541 http://bigdata.svn.sourceforge.net/bigdata/?rev=7541&view=rev Author: martyncutcher Date: 2013-11-13 17:22:34 +0000 (Wed, 13 Nov 2013) Log Message: ----------- Ensures that RWStore reset() synchronizes the metaTransientBits with the meteBits to protect committed allocations. Without this fix an HA service could become Leader with incorrect metabits protection, leading to problems seen in #738 where the HA followers were unable to correctly compute the delta on modified Allocators, leading to address resolution exceptions. The synchronization action has also been changed from a clone() to an arraycopy() to lessen heap pressure. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-11-13 17:22:17 UTC (rev 7540) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-11-13 17:22:34 UTC (rev 7541) @@ -1451,7 +1451,9 @@ for (int i = 0; i < m_metaBitsSize; i++) { m_metaBits[i] = strBuf.readInt(); } - m_metaTransientBits = (int[]) m_metaBits.clone(); + // m_metaTransientBits = (int[]) m_metaBits.clone(); + + syncMetaTransients(); final int numFixed = m_allocSizes.length; @@ -1478,6 +1480,20 @@ + ", " + m_metaBitsAddr); } } + + /** + * Uses System.arraycopy rather than clone() to duplicate the + * metaBits to the metaTransientBits, which will be faster. + */ + private void syncMetaTransients() { + if (m_metaTransientBits == null) { + m_metaTransientBits = (int[]) m_metaBits.clone(); + } else { + assert m_metaTransientBits.length == m_metaBits.length; + + System.arraycopy(m_metaBits, 0, m_metaTransientBits, 0, m_metaTransientBits.length); + } + } // /* // * Called when store is opened to make sure any deferred frees are @@ -2842,6 +2858,11 @@ isolatedWrites = isolatedWrites || fa.reset(m_writeCacheService, m_committedNextAllocation); } + /** + * Now clone the transient metabits for protection if this service becomes leader + */ + syncMetaTransients(); + if (!isolatedWrites) { /** * Now we should be able to unwind any unused allocators and unused @@ -3114,7 +3135,7 @@ // to provide control // writeFileSpec(); - m_metaTransientBits = (int[]) m_metaBits.clone(); + syncMetaTransients(); // Must be called from AbstractJournal commitNow after writeRootBlock // postCommit(); @@ -3500,6 +3521,9 @@ (b * cDefaultMetaBitsSize) + 1, cDefaultMetaBitsSize-1); if (ret != -1) { + // The assumption is that this bit is also NOT set in m_metaBits + assert !tstBit(m_metaBits, ret); + return ret; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2013-11-14 08:24:41
|
Revision: 7551 http://bigdata.svn.sourceforge.net/bigdata/?rev=7551&view=rev Author: martyncutcher Date: 2013-11-14 08:24:35 +0000 (Thu, 14 Nov 2013) Log Message: ----------- Fix invalid assertion in syncMetaTransients Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-11-14 00:49:09 UTC (rev 7550) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-11-14 08:24:35 UTC (rev 7551) @@ -1486,11 +1486,9 @@ * metaBits to the metaTransientBits, which will be faster. */ private void syncMetaTransients() { - if (m_metaTransientBits == null) { + if (m_metaTransientBits == null || m_metaTransientBits.length != m_metaBits.length) { m_metaTransientBits = (int[]) m_metaBits.clone(); } else { - assert m_metaTransientBits.length == m_metaBits.length; - System.arraycopy(m_metaBits, 0, m_metaTransientBits, 0, m_metaTransientBits.length); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-12-04 14:21:43
|
Revision: 7605 http://bigdata.svn.sourceforge.net/bigdata/?rev=7605&view=rev Author: thompsonbry Date: 2013-12-04 14:21:36 +0000 (Wed, 04 Dec 2013) Log Message: ----------- Possible bug fix for #778 from Martyn. The metabit addr was being incorrectly calculated in RWStore.postHACommit() at line 6239. was: {{{ final int metaBit = (i * cDefaultMetaBitsSize * 32) + (j * 32) + b; }}} now: {{{ final int metaBit = ((i + j) * 32) + b; }}} Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-12-03 21:27:25 UTC (rev 7604) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-12-04 14:21:36 UTC (rev 7605) @@ -6252,12 +6252,9 @@ m_committedNextAllocation = m_nextAllocation; - final long savedMetaBitsAddr = m_metaBitsAddr; // latched offset of the metabits region. m_metaBitsAddr = -(int) nxtOffset; - if (savedMetaBitsAddr != m_metaBitsAddr) - log.warn("Old metaBitsAddr: " + savedMetaBitsAddr + ", new metaBitsAddr: " + m_metaBitsAddr); } final ArrayList<FixedAllocator> nallocs = new ArrayList<FixedAllocator>(); @@ -6326,7 +6323,8 @@ log.trace("Allocator at: " + paddr); // metaBit - final int metaBit = (i * cDefaultMetaBitsSize * 32) + (j * 32) + b; +// final int metaBit = (i * cDefaultMetaBitsSize * 32) + (j * 32) + b; + final int metaBit = ((i + j) * 32) + b; // Now try to read it in final FixedAllocator nalloc = readAllocator(paddr); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-12-09 15:11:24
|
Revision: 7619 http://bigdata.svn.sourceforge.net/bigdata/?rev=7619&view=rev Author: thompsonbry Date: 2013-12-09 15:11:10 +0000 (Mon, 09 Dec 2013) Log Message: ----------- Picked up RWStore javadoc comment. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-12-09 15:10:58 UTC (rev 7618) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2013-12-09 15:11:10 UTC (rev 7619) @@ -6209,6 +6209,15 @@ * <p> * Note: Reads on the {@link RWStore} MUST block during this method since * some allocators may be replaced as part of the post-commit protocol. + * <p> + * Ticket #778 was for a problem when a follower takes over as leader and + * was not correctly synchronised. This was traced, eventually, to a problem + * in calculating the diskAddr metabit for the modified Allocator. The problem + * was demonstrated by a temporary method to reserve metaAllocations by extending and + * setting the m_transient bits. But that has to be done within the commit() method + * before it attempts to save all the dirty allocators. If we need to contrive a similar + * scenario in the future a better approach would be a special debug property on the + * RWStore that indicates a "TRANSIENT_RESERVE" or something similar. * * @param rbv * The new {@link IRootBlockView}. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2014-06-10 13:01:48
|
Revision: 8456 http://sourceforge.net/p/bigdata/code/8456 Author: martyncutcher Date: 2014-06-10 13:01:39 +0000 (Tue, 10 Jun 2014) Log Message: ----------- Implements a demi-space metaBits allocation to remove problems associated with storing the metaBits in a FixedAllocator slot. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2014-06-09 19:30:26 UTC (rev 8455) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2014-06-10 13:01:39 UTC (rev 8456) @@ -306,6 +306,11 @@ * should be tuned to target perhaps 80% of an 8k page in order to have * only a small number of pages that spill over into blobs. * + * TODO: We should consider a more adaptable BLOB approach where we + * specify the maximum "slop" in an allocation as the means to determine + * a blob boundary. So, for example, a 5.5K allocation, with maximum slop of + * 1K, would be allocated as a blob of 4K + 2K and not an 8K slot. + * * @see #ALLOCATION_SIZES */ String DEFAULT_ALLOCATION_SIZES = "1, 2, 3, 5, 8, 12, 16, 32, 48, 64, 128"; @@ -321,12 +326,25 @@ * <p> * Note: A value of <code>9</code> may be used to stress the logic which * is responsible for the growth in the meta bits region. + * <p> + * This has now been deprecated since it adds complexity with no significant benefit */ - String META_BITS_SIZE = RWStore.class.getName() + ".metaBitsSize"; + @Deprecated String META_BITS_SIZE = RWStore.class.getName() + ".metaBitsSize"; - String DEFAULT_META_BITS_SIZE = "9"; + @Deprecated String DEFAULT_META_BITS_SIZE = "9"; /** + * Defines whether the metabits should be allocated an explicit demispace (default) + * or if not, then to use a standard Allocation (which limits the metabits size to + * the maximum FixedAllocator slot size). + * <p> + * The value should be either "true" or "false" + */ + String META_BITS_DEMI_SPACE = RWStore.class.getName() + ".metabitsDemispace"; + + String DEFAULT_META_BITS_DEMI_SPACE = "true"; + + /** * Defines the number of bits that must be free in a FixedAllocator for * it to be added to the free list. This is used to ensure a level * of locality when making large numbers of allocations within a single @@ -398,7 +416,7 @@ static final int OFFSET_BITS = 13; static final int OFFSET_BITS_MASK = 0x1FFF; // was 0xFFFF - static final int ALLOCATION_SCALEUP = 16; // multiplier to convert allocations based on minimum allocation of 32k + static final int ALLOCATION_SCALEUP = 16; // multiplier to convert allocations based on minimum allocation of 64k static private final int META_ALLOCATION = 8; // 8 * 32K is size of meta Allocation // If required, then allocate 1M direct buffers @@ -771,16 +789,29 @@ log.info(AbstractTransactionService.Options.MIN_RELEASE_AGE + "=" + m_minReleaseAge); - cDefaultMetaBitsSize = Integer.valueOf(fileMetadata.getProperty( - Options.META_BITS_SIZE, - Options.DEFAULT_META_BITS_SIZE)); + // Remove parameterisation, we want to use fixed Allocator block sizing + // there is no significant advantage to parameterize this since file cache + // locality is handled by size of the allocation - 256K is a reasonable + // number as 32 * 8 * 1K size. + // + // Equally there is no benefit to increasing the size of the Allocators beyond + // 1K. +// cDefaultMetaBitsSize = Integer.valueOf(fileMetadata.getProperty( +// Options.META_BITS_SIZE, +// Options.DEFAULT_META_BITS_SIZE)); + +// cDefaultMetaBitsSize = 9; - if (cDefaultMetaBitsSize < 9) - throw new IllegalArgumentException(Options.META_BITS_SIZE - + " : Must be GTE 9"); +// if (cDefaultMetaBitsSize < 9) +// throw new IllegalArgumentException(Options.META_BITS_SIZE +// + " : Must be GTE 9"); m_metaBitsSize = cDefaultMetaBitsSize; + m_useMetabitsDemispace = Boolean.valueOf(fileMetadata.getProperty( + Options.META_BITS_DEMI_SPACE, + Options.DEFAULT_META_BITS_DEMI_SPACE)); + cDefaultFreeBitsThreshold = Integer.valueOf(fileMetadata.getProperty( Options.FREE_BITS_THRESHOLD, Options.DEFAULT_FREE_BITS_THRESHOLD)); @@ -1419,6 +1450,14 @@ * allocators. So, 16-bits gives us up 64k * 32 = 2M allocators. * Except, that the total #of allocators is reduced by the presence * of a startAddr every N positions in the metaBits[]. + * + * The theoretical maximum number is also reduced since the number + * of "committed" bits could be half the total number of bits. + * + * The theoretical restriction is also limited by the maximum indexable + * allocator, since only 19 bits is available to the index, which, once + * the sign is removed reduces the maximum number of addressable + * allocators to 256K. */ final int metaBitsStore = (int) (rawmbaddr & 0xFFFF); @@ -1445,7 +1484,9 @@ + storeVersion + ", cVersion=" + cVersion); } m_lastDeferredReleaseTime = strBuf.readLong(); - cDefaultMetaBitsSize = strBuf.readInt(); + if (strBuf.readInt() != cDefaultMetaBitsSize) { + throw new IllegalStateException("Store opened with unsupported metabits size"); + } final int allocBlocks = strBuf.readInt(); m_storageStatsAddr = strBuf.readLong(); @@ -1483,12 +1524,6 @@ readAllocationBlocks(); - // clearOutstandingDeferrels(deferredFreeListAddr, deferredFreeListEntries); - - if (physicalAddress(m_metaBitsAddr) == 0) { - throw new IllegalStateException("Free/Invalid metaBitsAddr on load"); - } - } if (log.isInfoEnabled()) @@ -2963,6 +2998,25 @@ * last one being the allocation for the metabits themselves (allowing for * an extension!). * + * Ticket #936: The meta-bits allocation is currently made from the FixedAllocator + * region. This works well providing the required allocation bits is less than + * the maximum FixedAllocator slot size. While this is neat, there are problems at scale + * for maximum slot sizes less than 64K. + * + * To address the 8K bits in a 1K alloctor, 13 bits are required, this leaves 19 bits + * to index an Allocator, or 18 bits without the sign => 256K maximum index. + * + * To be able to commit changes to all 256K allocators requires 512K metabits => 64K bytes. + * We would like to associate the 64K allocations with the root block, so a single 128K + * allocation would be split into 64K demi-spaces, one for each root block. + * + * While a negative address indicates a standard RW allocation a ositive address can be used + * to indicate an explicitly allocated region. The trick is to ensure that the region is + * allocated on a 128K boundary, then the lower bits can indicate which demi-space is used with + * a simple XOR. + * + * Note that we must ensure that any previous demi-space write is removed from the WCS. + * * @throws IOException */ private void writeMetaBits() throws IOException { @@ -3013,7 +3067,8 @@ * Note: this address is set by commit() prior to calling * writeMetaBits(). */ - final long addr = physicalAddress(m_metaBitsAddr); + //final long addr = physicalAddress(m_metaBitsAddr); + final long addr = ((long) m_metaBitsAddr) << ALLOCATION_SCALEUP; if (addr == 0) { throw new IllegalStateException("Invalid metabits address: " + m_metaBitsAddr); } @@ -3024,7 +3079,9 @@ if (log.isDebugEnabled()) log.debug("writing metabits at: " + addr); - m_writeCacheService.write(addr, ByteBuffer.wrap(buf), 0/*chk*/, false/*useChecksum*/, m_metaBitsAddr/*latchedAddr*/); + // Similar to writeMetaBits, we are no longer writing to a FixedAllocator managed region, + // so no latched address is provided + m_writeCacheService.write(addr, ByteBuffer.wrap(buf), 0/*chk*/, false/*useChecksum*/, 0 /*latchedAddr*/); } catch (InterruptedException e) { throw new RuntimeException(e); } @@ -3077,19 +3134,41 @@ * that we do not need to reallocate the metabits region when we are * writing out the updated versions of the FixedAllocators). */ - final long oldMetaBits = m_metaBitsAddr; - final int oldMetaBitsSize = (m_metaBits.length + m_allocSizes.length + 1) * 4; - m_metaBitsAddr = alloc(getRequiredMetaBitsStorage(), null); +// final long oldMetaBits = m_metaBitsAddr; +// final int oldMetaBitsSize = (m_metaBits.length + m_allocSizes.length + 1) * 4; +// m_metaBitsAddr = alloc(getRequiredMetaBitsStorage(), null); - // DEBUG SANITY CHECK! + /* + * If m_metaBitsAddr < 0 then was allocated from FixedAllocators (for existing-store compatibility) + */ + if (m_metaBitsAddr < 0) { if (physicalAddress(m_metaBitsAddr) == 0) { throw new IllegalStateException("Returned MetaBits Address not valid!"); } + final int oldMetaBitsSize = (m_metaBits.length + m_allocSizes.length + 1) * 4; // Call immediateFree - no need to defer freeof metaBits, this // has to stop somewhere! // No more allocations must be made - immediateFree((int) oldMetaBits, oldMetaBitsSize); + immediateFree((int) m_metaBitsAddr, oldMetaBitsSize); + + m_metaBitsAddr = 0; + } + + if (m_metaBitsAddr == 0) { + // Allocate special region to be able to store maximum metabits (128k of 2 64K demi-space + // Must be aligned on 128K boundary and allocations are made in units of 64K. + while (m_nextAllocation % 2 != 0) { + m_nextAllocation--; + } + m_metaBitsAddr = -m_nextAllocation; // must be positive to differentiate from FixedAllocator address + m_nextAllocation -= 2; // allocate 2 * 64K + } else { // remove previous write from WCS + m_writeCacheService.removeWriteToAddr(convertAddr(-m_metaBitsAddr), 0); + } + + // Now "toggle" m_metaBitsAddr - 64K boundary + m_metaBitsAddr ^= 0x01; // toggle zero or 64K offset // There must be no buffered deferred frees // assert m_deferredFreeOut.getBytesWritten() == 0; @@ -3397,11 +3476,13 @@ /** * @see Options#META_BITS_SIZE */ - private int cDefaultMetaBitsSize; + final private int cDefaultMetaBitsSize = 9; /** * @see Options#META_BITS_SIZE */ volatile private int m_metaBitsSize; + + volatile private boolean m_useMetabitsDemispace = true; /** * Package private since is uded by FixedAllocators * @@ -4146,11 +4227,17 @@ } /** - * The + * Since we need to store the absolute address and the size can be + * a maximum of 64K, the absolute address is limited to 48 bits, setting + * the maximum address as 140T, which is sufficient. + * * @return long representation of metaBitsAddr PLUS the size */ public long getMetaBitsAddr() { - long ret = physicalAddress((int) m_metaBitsAddr); + assert m_metaBitsAddr > 0; + + // long ret = physicalAddress((int) m_metaBitsAddr); + long ret = convertAddr(-m_metaBitsAddr); // maximum 48 bit address range ret <<= 16; // include space for version, allocSizes and deferred free info AND cDefaultMetaBitsSize @@ -4166,6 +4253,14 @@ } /** + * + * @return the address of the metaBits demi-space + */ + public long getMetaBitsDemiSpace() { + return convertAddr(-m_metaBitsAddr); + } + + /** * @return long representation of metaStartAddr PLUS the size where addr + * size is fileSize (not necessarily physical size) */ @@ -4180,6 +4275,10 @@ */ public long getNextOffset() { long ret = -m_nextAllocation; + if (m_metaBitsAddr > 0) { + // FIX for sign use in m_metaBitsAddr when packing into long + ret++; + } ret <<= 32; ret += -m_metaBitsAddr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-06-30 13:10:34
|
Revision: 8511 http://sourceforge.net/p/bigdata/code/8511 Author: thompsonbry Date: 2014-06-30 13:10:31 +0000 (Mon, 30 Jun 2014) Log Message: ----------- javadoc on the metabits util and linked it to the ticket and the data migration pages. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2014-06-30 13:09:38 UTC (rev 8510) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2014-06-30 13:10:31 UTC (rev 8511) @@ -3487,6 +3487,15 @@ * 0x0500 - using metaBits demi-space */ final private int cVersion = 0x0400; + /** + * The {@link #cVersion} value corresponding to the use of the demi-space + * for the metabits. + * + * @see <a href="http://trac.bigdata.com/ticket/936"> Support larger metabit + * allocations</a> + * @see <a href="http://wiki.bigdata.com/wiki/index.php/DataMigration" > + * Data migration </a> + */ final private int cVersionDemispace = 0x0500; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |