From: <tho...@us...> - 2010-11-18 19:14:12
|
Revision: 3967 http://bigdata.svn.sourceforge.net/bigdata/?rev=3967&view=rev Author: thompsonbry Date: 2010-11-18 19:14:05 +0000 (Thu, 18 Nov 2010) Log Message: ----------- Added exception to help identify problems where the caller reading against a historical commit point is not using a read-only transaction and hence is not protected by a read-lock. Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java branches/JOURNAL_HA_BRANCH/bigdata/src/samples/com/bigdata/samples/btree/JournalReadOnlyTxExample.java Added Paths: ----------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/PhysicalAddressResolutionException.java Added: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/PhysicalAddressResolutionException.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/PhysicalAddressResolutionException.java (rev 0) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/PhysicalAddressResolutionException.java 2010-11-18 19:14:05 UTC (rev 3967) @@ -0,0 +1,54 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* + * Created on Nov 18, 2010 + */ + +package com.bigdata.rwstore; + +/** + * Exception thrown when a logical address maps onto a physical address which is + * not currently allocated. The most common cause of this exception is a read on + * the database using a historical commit point which is not protected by a read + * lock. You should be using a read-only transaction rather than a bare + * historical read in order to be protected by a read lock. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class PhysicalAddressResolutionException extends + IllegalArgumentException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public PhysicalAddressResolutionException(final long addr) { + + super("Address did not resolve to physical address: " + addr); + + } + +} Property changes on: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/PhysicalAddressResolutionException.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2010-11-18 18:33:30 UTC (rev 3966) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2010-11-18 19:14:05 UTC (rev 3967) @@ -1258,12 +1258,7 @@ assertAllocators(); - final String msg = "Address did not resolve to physical address: " - + addr; - - log.warn(msg); - - throw new IllegalArgumentException(msg); + throw new PhysicalAddressResolutionException(addr); } Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/samples/com/bigdata/samples/btree/JournalReadOnlyTxExample.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/samples/com/bigdata/samples/btree/JournalReadOnlyTxExample.java 2010-11-18 18:33:30 UTC (rev 3966) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/samples/com/bigdata/samples/btree/JournalReadOnlyTxExample.java 2010-11-18 19:14:05 UTC (rev 3967) @@ -171,10 +171,20 @@ } - /* - * Open a read-only transaction on the last commit time. - */ - final long tx2 = store.newTx(ITx.READ_COMMITTED); + /* + * Open a read-only transaction on the last commit time. + * + * Note: If you use store.getLastCommitTime() here instead you will + * have a read-historical view of the same data, but that view is + * NOT protected by a read lock. Running the example with this + * change will cause the RWStore to throw out an exception since the + * writes will have overwritten the historical data by the time you + * try to read it. + */ + // Obtaining a tx here protects against recycling. +// final long tx2 = store.newTx(ITx.READ_COMMITTED); + // Using a historical read w/o a tx does NOT protect against recycling. + final long tx2 = store.getLastCommitTime(); try { // lookup the UNISOLATED B+Tree. @@ -186,30 +196,20 @@ store.commit(); /* - * Verify that the read-only view has not seen those changes. - */ - if(false) { - final BTree readOnlyBTree = (BTree) store.getIndex(name, tx2); - - verifyWriteSet1(readOnlyBTree); - - } - - /* * Write some new records on the unisolated index. */ writeSet2(unisolatedBTree); store.commit(); - - /* - * Verify that the read-only view has not seen those changes. - * - * Note: This probably hits the index cache and everything in - * the read-only B+Tree was already materialized when we - * verified it just before writing writeSet2 onto the unisolated - * index, so this is not really testing anything. - */ + + /* + * Verify that the read-only view has not seen those changes. + * + * Note: If you used a historical read rather than a read-only + * tx then this is where the RWStore will throw out an exception + * because the recycled has reused some of the records + * associated with the historical revision of the BTree. + */ { final BTree readOnlyBTree = (BTree) store.getIndex(name, tx2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |