Cleaned up some calls that are not being used in log facttory. Attached
is the diff file. I am not sure how
patch command handles deleted files. Following are the files that are
deleted in the submitted patch:
D java\engine\org\apache\derby\impl\store\raw\log\SaveLWMOperation.java
D java\engine\org\apache\derby\impl\store\raw\log\TruncationPoint.java
D
java\engine\org\apache\derby\impl\store\raw\log\D_TruncationPoint.java
Thanks
-suresht
Index: java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/xact/Xact.java (revision 55271)
+++ java/engine/org/apache/derby/impl/store/raw/xact/Xact.java (working copy)
@@ -1512,28 +1512,7 @@
return savePoints.size();
}
- /**
- @exception StandardException Standard cloudscape exception
policy
- */
- public void addTruncationLWM(UUID name, LogInstant instant)
- throws StandardException
- {
- setActiveState();
- logFactory.setTruncationLWM(name, instant);
- }
-
- /**
- @exception StandardException Standard cloudscape exception
policy
- */
- public void removeTruncationLWM(UUID name) throws StandardException
- {
- setActiveState();
-
- logFactory.removeTruncationLWM(name);
- }
-
-
/*
** Implementation specific methods
*/
Index: java/engine/org/apache/derby/impl/store/raw/log/SaveLWMOperation.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/log/SaveLWMOperation.java
(revision 55271)
+++ java/engine/org/apache/derby/impl/store/raw/log/SaveLWMOperation.java
(working copy)
@@ -1,173 +0,0 @@
-/*
-
- Licensed Materials - Property of IBM
- Cloudscape - Package org.apache.derby.impl.store.raw.log
- (C) Copyright IBM Corp. 1997, 2004. All Rights Reserved.
- US Government Users Restricted Rights - Use, duplication or
- disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-
- */
-
-package org.apache.derby.impl.store.raw.log;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.services.io.FormatIdUtil;
-import org.apache.derby.iapi.services.io.StoredFormatIds;
-import org.apache.derby.catalog.UUID;
-
-import org.apache.derby.iapi.store.raw.Transaction;
-import org.apache.derby.iapi.store.raw.Loggable;
-import org.apache.derby.iapi.store.raw.log.LogInstant;
-import org.apache.derby.iapi.store.raw.xact.RawTransaction;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.io.CompressedNumber;
-import org.apache.derby.iapi.util.ByteArray;
-
-import java.io.OutputStream;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.IOException;
-import org.apache.derby.iapi.services.io.LimitObjectInput;
-
-/**
- A Log Operation that record the truncation low water marks
- @see Loggable
-*/
-public final class SaveLWMOperation implements Loggable
-{
- /**
- IBM Copyright © notice.
- */
- public static final String copyrightNotice =
org.apache.derby.iapi.reference.Copyright.SHORT_1997_2004;
- // log trunaction point - when a SaveLWMOperation is read from the log
- // during recovery, the truncation LWM is added to the truncation lwm
table
- //
- // A checkpoint log record has the complete truncation lwm record.
- // Since removal of a truncation point is not logged, every time a
- // checkpoint log record is encouter, all truncation lwm will be reset
- // based on information in that operation.
- private UUID name;
- private LogInstant LWMinstant;
- private boolean set; // to set or unset this LWM
-
- public SaveLWMOperation(UUID name, LogInstant instant, boolean set)
- {
- this.name = name;
- this.LWMinstant = instant;
- this.set = set;
- }
-
- /*
- * Formatable methods
- */
-
- // no-arg constructor, required by Formatable
- public SaveLWMOperation() { super(); }
-
- public void writeExternal(ObjectOutput out) throws IOException
- {
- out.writeBoolean(set);
- out.writeObject(name);
-
- long l = LogCounter.INVALID_LOG_INSTANT;
-
- if (LWMinstant != null)
- l = ((LogCounter)LWMinstant).getValueAsLong();
-
- CompressedNumber.writeLong(out, l);
- }
-
- public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException
- {
- set = in.readBoolean();
- name = (UUID)in.readObject();
- long l = CompressedNumber.readLong(in);
-
- if (l != LogCounter.INVALID_LOG_INSTANT)
- LWMinstant = new LogCounter(l);
- else
- LWMinstant = null;
- }
-
- /**
- Return my format identifier.
- */
- public int getTypeFormatId() {
- return StoredFormatIds.LOGOP_SAVE_LWM;
- }
-
- /**
- Add truncation lwm
- @exception StandardException Standard Cloudscape error policy
- */
- public void doMe(Transaction xact, LogInstant instant, LimitObjectInput
in)
- throws StandardException
- {
- if (set)
- ((RawTransaction)xact).addTruncationLWM(name,
LWMinstant);
- else
- ((RawTransaction)xact).removeTruncationLWM(name);
- }
-
- /**
- the default for prepared log is always null for all the
operations
- that don't have optionalData. If an operation has optional
data,
- the operation need to prepare the optional data for this method.
-
- This operation has no optional data to write out
- */
- public ByteArray getPreparedLog()
- {
- return (ByteArray) null;
- }
-
- /**
- Always redo
- */
- public boolean needsRedo(Transaction xact)
- {
- return true;
- }
-
- /**
- no resource to release
- */
- public void releaseResource(Transaction xact)
- {}
-
- /**
- a raw store operation
- */
- public int group()
- {
- return Loggable.RAWSTORE;
- }
-
-
- public TruncationPoint truncationLWM()
- {
- return new TruncationPoint(name, LWMinstant);
- }
-
- /**
- DEBUG: Print self.
- */
- public String toString()
- {
- if (SanityManager.DEBUG)
- {
- LogCounter logLWM = (LogCounter)LWMinstant;
- String str = set ? " SET " : " UNSET ";
-
- return str + "SaveLWMOperation : truncation point " +
name + " " + logLWM;
-
- }
- else
- return null;
- }
-
-
-}
Index: java/engine/org/apache/derby/impl/store/raw/log/TruncationPoint.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/log/TruncationPoint.java
(revision 55271)
+++ java/engine/org/apache/derby/impl/store/raw/log/TruncationPoint.java
(working copy)
@@ -1,55 +0,0 @@
-/*
-
- Licensed Materials - Property of IBM
- Cloudscape - Package org.apache.derby.impl.store.raw.log
- (C) Copyright IBM Corp. 1997, 2004. All Rights Reserved.
- US Government Users Restricted Rights - Use, duplication or
- disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-
- */
-
-package org.apache.derby.impl.store.raw.log;
-
-import org.apache.derby.iapi.store.raw.log.LogInstant;
-import org.apache.derby.catalog.UUID;
-
-/**
- TruncationPoint is used to store truncationLWM.
- This class is MT-unsafe, caller of this class must provide synchronization
-*/
-public class TruncationPoint
-{
- /**
- IBM Copyright © notice.
- */
- public static final String copyrightNotice =
org.apache.derby.iapi.reference.Copyright.SHORT_1997_2004;
- UUID name;
- LogInstant instant;
-
- public TruncationPoint(UUID name, LogInstant instant)
- {
- this.name = name;
- this.instant = instant;
- }
-
- public boolean isEqual(UUID name)
- {
- return this.name.equals(name);
- }
-
- public void setLogInstant(LogInstant instant)
- {
- this.instant = instant;
- }
-
- public LogInstant getLogInstant()
- {
- return instant;
- }
-
- public UUID getName()
- {
- return name;
- }
-
-}
Index: java/engine/org/apache/derby/impl/store/raw/log/D_TruncationPoint.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/log/D_TruncationPoint.java
(revision 55271)
+++ java/engine/org/apache/derby/impl/store/raw/log/D_TruncationPoint.java
(working copy)
@@ -1,41 +0,0 @@
-/*
-
- Licensed Materials - Property of IBM
- Cloudscape - Package org.apache.derby.impl.store.raw.log
- (C) Copyright IBM Corp. 1998, 2004. All Rights Reserved.
- US Government Users Restricted Rights - Use, duplication or
- disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-
- */
-
-package org.apache.derby.impl.store.raw.log;
-
-import org.apache.derby.impl.store.raw.log.LogCounter;
-import org.apache.derby.iapi.services.diag.DiagnosticUtil;
-import org.apache.derby.iapi.services.diag.Diagnosticable;
-import org.apache.derby.iapi.services.diag.DiagnosticableGeneric;
-import org.apache.derby.iapi.error.StandardException;
-
-public class D_TruncationPoint
-extends DiagnosticableGeneric
-{
- /**
- IBM Copyright © notice.
- */
- public static final String copyrightNotice =
org.apache.derby.iapi.reference.Copyright.SHORT_1998_2004;
- /**
- @exception StandardException Oops.
- @see Diagnosticable#diag
- */
- public String diag()
- throws StandardException
- {
- TruncationPoint tp = (TruncationPoint)diag_object;
- StringBuffer r = new StringBuffer();
- r.append("TruncationPoint: ");
- r.append(" name: "+tp.name);
- r.append(" instant: "+
- DiagnosticUtil.toDiagString(tp.instant));
- return r.toString();
- }
-}
Index: java/engine/org/apache/derby/impl/store/raw/log/CheckpointOperation.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/log/CheckpointOperation.java
(revision 55271)
+++ java/engine/org/apache/derby/impl/store/raw/log/CheckpointOperation.java
(working copy)
@@ -53,19 +53,12 @@
// undo LWM
protected long undoLWM;
- // other log trunaction points - after the checkpoint is read from the
log
- // after a recovery, the array is then used to populate the in memory
- // truncation lwm table.
- protected TruncationPoint[] truncationLWM;
-
protected Formatable transactionTable;
- public CheckpointOperation(long redoLWM, long undoLWM,
- TruncationPoint[]
tpoints, Formatable ttab)
+ public CheckpointOperation(long redoLWM, long undoLWM, Formatable ttab)
{
this.redoLWM = redoLWM;
this.undoLWM = undoLWM;
- this.truncationLWM = tpoints;
this.transactionTable = ttab;
}
@@ -80,20 +73,9 @@
{
CompressedNumber.writeLong(out, redoLWM);
CompressedNumber.writeLong(out, undoLWM);
- if (truncationLWM == null)
- CompressedNumber.writeInt(out, 0); // no other
truncation LWM
- else
- {
- CompressedNumber.writeInt(out, truncationLWM.length);
- for (int i = 0; i < truncationLWM.length; i++)
- {
- out.writeObject(truncationLWM[i].getName());
+ // RESOLVE: Following write Not needed, keeping it to avoid
upgrade/downgrade issues.
+ CompressedNumber.writeInt(out, 0); // no other truncation
LWM
- LogCounter l =
(LogCounter)(truncationLWM[i].getLogInstant());
-
CompressedNumber.writeLong(out,l.getValueAsLong());
- }
- }
-
if (transactionTable == null)
CompressedNumber.writeInt(out, 0);
else
@@ -108,24 +90,9 @@
redoLWM = CompressedNumber.readLong(in);
undoLWM = CompressedNumber.readLong(in);
+ // RESOLVE: Following read Not required, keeping it to avoid
upgrade/downgrade issues.
int tsize = CompressedNumber.readInt(in); // is there any
truncationLWM?
- if (tsize == 0)
- truncationLWM = null;
- else
- {
- truncationLWM = new TruncationPoint[tsize];
- UUID name;
- LogInstant instant;
- for (int i = 0; i < tsize; i++)
- {
- name = (UUID)in.readObject();
-
- long l = CompressedNumber.readLong(in);
- truncationLWM[i] = new TruncationPoint(name,
new LogCounter(l));
- }
- }
-
int haveTTab = CompressedNumber.readInt(in);
if (haveTTab == 1)
transactionTable = (Formatable)in.readObject();
@@ -219,10 +186,6 @@
return undoLWM;
}
- public TruncationPoint[] truncationLWM()
- {
- return truncationLWM;
- }
public Formatable getTransactionTable()
{
@@ -244,17 +207,6 @@
.append(redolwm.toString())
.append("\n\t\tundoLWM
").append(undolwm.toString());
- if (truncationLWM != null)
- {
- LogCounter logLWM;
- for (int i = truncationLWM.length-1; i >= 0;
i--)
- {
- logLWM =
(LogCounter)(truncationLWM[i].getLogInstant());
- str.append(" truncation point
").append(i)
- .append("
").append(logLWM.toString());
- }
- }
-
if (transactionTable != null)
{
str.append(transactionTable.toString());
Index: java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
(revision 55271)
+++ java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
(working copy)
@@ -16,8 +16,6 @@
import org.apache.derby.impl.store.raw.log.LogCounter;
import org.apache.derby.impl.store.raw.log.LogRecord;
import org.apache.derby.impl.store.raw.log.StreamLogScan;
-import org.apache.derby.impl.store.raw.log.SaveLWMOperation;
-import org.apache.derby.impl.store.raw.log.TruncationPoint;
// need this to print nested exception that corrupts the database
import org.apache.derby.iapi.services.context.ErrorStringBuilder;
@@ -350,22 +348,11 @@
private boolean recoveryNeeded = true; // log needs to
be recovered
private boolean inCheckpoint = false; // in the
middle of a checkpoint
private boolean inRedo = false; // in the
middle of redo loop
- private boolean movingTruncPt = false; // in the
middle of moving
-
// a truncationLWM
private boolean inLogSwitch = false;
// make sure we don't do anything after the log factory has been stopped
private boolean stopped = false;
- Vector truncPoints; // a list of
truncationLWM
- //
- // MT - This
value is set during recovery or
- // during
set/remove TruncationLWM. In the
- // former
single thread is assumed. In the
- // latter must
synchronized on this for
- // access or
change.
-
-
// if log is to go to another device, this variable is set. If null,
then
// log goes to the log subdirectory underneath the data directory
String logDevice;
@@ -715,24 +702,7 @@
LogCounter.getLogFileNumber(undoLWM);
}
- TruncationPoint[] tpoints =
-
currentCheckpoint.truncationLWM();
- if (tpoints != null)
- {
- LogInstant earliestLWM =
restoreTruncationLWMs(tpoints);
-
- if (earliestLWM != null)
- {
- if
(((LogCounter)earliestLWM).getLogFileNumber() <
- firstLogFileNumber)
- {
-
firstLogFileNumber =
-
((LogCounter)earliestLWM).getLogFileNumber();
- }
- }
- }
-
// if the checkpoint record doesn't
have a transaction
// table, we need to rebuild it by
scanning the log from
// the undoLWM. If it does have a
transaction table, we
@@ -1504,35 +1474,9 @@
// send the checkpoint record to the log
Formatable transactionTable = tf.getTransactionTable();
- // If the truncpoint changes between this time and the
time the
- // checkpoint log record gets written to disk, this is
not a
- // problem. During recovery, we first get the
truncation points
- // from the checkpoint. Then during redo, we will
encounter any
- // changes that ever happen to the set of truncation
LWMs, so we
- // will end up picking up everything up to the point of
crash.
- TruncationPoint[] tpoints = null;
- synchronized(this)
- {
- if (truncPoints != null)
- {
- // make a snap shot copy of all the
truncation LWMs
-
- int numTpoints = truncPoints.size();
-
- tpoints = new
TruncationPoint[numTpoints];
- TruncationPoint t;
- for (int i = 0; i < numTpoints; i++)
- {
- t =
(TruncationPoint)truncPoints.elementAt(i);
- tpoints[i] =
- new TruncationPoint(t.getName(),
t.getLogInstant());
- }
- }
- }
-
CheckpointOperation nextCheckpoint =
new CheckpointOperation(
- redoLWM_long, undoLWM_long, tpoints, transactionTable);
+ redoLWM_long, undoLWM_long, transactionTable);
cptran.logAndDo(nextCheckpoint);
@@ -2115,9 +2059,6 @@
// one truncation at a time
synchronized (this)
{
- if (movingTruncPt) // don't truncate the log while
someone is mucking
- return -1; // with
truncation LWMs
-
firstLogNeeded =
LogCounter.getLogFileNumber(checkpoint.undoLWM());
if (SanityManager.DEBUG)
@@ -2126,45 +2067,10 @@
SanityManager.DEBUG(DBG_FLAG,
"truncatLog: undoLWM firstlog needed " + firstLogNeeded);
}
- if (truncPoints != null) // other interesting
truncation point in memory
- {
- TruncationPoint p;
- LogCounter logLWM;
- for (int i = truncPoints.size()-1; i >=0; i--)
- {
- p =
(TruncationPoint)truncPoints.elementAt(i);
- logLWM =
(LogCounter)(p.getLogInstant());
- if (firstLogNeeded >
logLWM.getLogFileNumber())
- firstLogNeeded =
logLWM.getLogFileNumber();
- }
- }
-
if (SanityManager.DEBUG)
{
if (SanityManager.DEBUG_ON(LogToFile.DBG_FLAG))
- SanityManager.DEBUG(DBG_FLAG,
"truncatLog: in memory truncationLWM firstlog needed " + firstLogNeeded);
- }
-
- // now go thru the current checkpoint log record.
Somebody may
- // have change the truncation LWM between the time the
- // checkpoint record snapshot was taken and now. And
we better
- // not truncate and violate either set of LWMs
- TruncationPoint[] tps = checkpoint.truncationLWM();
- if (tps != null)
- {
- LogCounter logLWM;
- for (int i = tps.length-1; i >= 0; i--)
{
- logLWM =
(LogCounter)(tps[i].getLogInstant());
- if (firstLogNeeded >
logLWM.getLogFileNumber())
- firstLogNeeded =
logLWM.getLogFileNumber();
- }
- }
-
- if (SanityManager.DEBUG)
- {
- if (SanityManager.DEBUG_ON(LogToFile.DBG_FLAG))
- {
SanityManager.DEBUG(DBG_FLAG, "truncatLog:
checkpoint truncationLWM firstlog needed " + firstLogNeeded);
SanityManager.DEBUG(DBG_FLAG, "truncatLog:
firstLogFileNumber = " + firstLogFileNumber);
}
@@ -3801,300 +3707,8 @@
}
}
- /*
- * trunction LWM support
- */
/**
- Set or add a truncationLWM with the given name. If instant is null,
- set the truncationLWM to the beginning of the log. The
truncation point
- is guaranteed to be durable.
-
- <P>MT - MT safe
-
- @exception StandardException Standard cloudscape exception
policy
- */
- public LogInstant setTruncationLWM(UUID name,
-
LogInstant instant,
-
RawStoreFactory rsf,
-
TransactionFactory tf)
- throws StandardException
- {
- checkCorrupt();
-
- if (SanityManager.DEBUG)
- SanityManager.ASSERT(name != null, "null UUID name");
-
-
- synchronized(this)
- {
- if (instant == null)
- instant = new LogCounter(firstLogInstant());
- else
- {
- long firstlog = firstLogInstant();
- long instant_long =
((LogCounter)instant).getValueAsLong();
-
- // make sure it is legal
- if (instant_long < firstlog || instant_long >
currentInstant())
- {
- throw StandardException.newException(
- SQLState.LOG_TRUNC_LWM_ILLEGAL,
- name, instant,
- new LogCounter(firstlog),
- new LogCounter(currentInstant()));
- }
- }
-
- // Set it now before we log it so that we won't
truncate the log in
- // between. This will stablelize the head of the log if
this is
- // setting the first truncation LWM or setting it
backwards.
- setTruncationLWM(name, instant);
-
- // If we move the truncation point forward, need to
prevent log
- // truncation from happening until AFTER the log record
is written
- // and log is flushed, otherwise, if the log is
truncated before
- // the SaveLWM operation is sent to the log stream, the
previous
- // LWM will point to a non-existant log record if the
system
- // crashed in the middle.
- movingTruncPt = true;
- }
-
- RawTransaction itran = null;
- try
- {
-
- // log it to make it durable
- Loggable lop = new SaveLWMOperation(name, instant, true
/* set */);
-
- // start an internal transaction to log this
- itran = tf.startInternalTransaction(rsf,
ContextService.getFactory().getCurrentContextManager());
- itran.logAndDo(lop);
- itran.commit();
-
- // flush the log
- synchronized (this) {
- flush(logFileNumber, endPosition);
- }
-
- itran.close();
- itran = null;
- }
- finally
- {
- // allow log truncation to proceed
- synchronized(this)
- {
- movingTruncPt = false;
- }
-
- if (itran != null)
- {
- itran.abort();
- itran.close();
- }
-
- }
-
- return instant;
- }
-
- /**
- Set or add a truncationLWM with the given name and log instance.
- This is called underneath the log.
-
- <P>MT - MT unsafe, caller provide synchronization
-
- @exception StandardException if the given log instant is older
than the
- first log instance known to this log factory, an exception will
be thrown
- */
- public void setTruncationLWM(UUID name, LogInstant instant)
- throws StandardException
- {
- if (stopped)
- {
- throw StandardException.newException(SQLState.LOG_FACTORY_STOPPED);
- }
-
- if (inRedo)
- {
- // in recovery - if this sets the truncation point
further back
- // from where the current checkpoint sets the first
log, it is not
- // a problem (as long as the log file is still there,
which
- // hopefully it is).
-
- // This can come about if the checkpoint is taken and
- // determined that the first useful log is N. Before
log
- // file N-1 is truncated, a setTruncationLWM with null
- // instant is called, which sets it to N-1.
- // Before the next checkpoint is taken, the system
crashed.
- if (firstLogFileNumber < 0 ||
((LogCounter)instant).getLogFileNumber() < firstLogFileNumber)
- firstLogFileNumber =
((LogCounter)instant).getLogFileNumber();
- }
-
- TruncationPoint tpoint = null;
-
- synchronized(this)
- {
- if (truncPoints == null)
- truncPoints = new Vector(1, 1);
- else
- tpoint = findTruncPoint(name);
-
- // not an existing truncationLWM. Add it to the list
- if (tpoint == null)
- {
- tpoint = new TruncationPoint(name, instant);
- truncPoints.addElement(tpoint);
- }
- else
- {
- // existing truncaionLWM, change it,
- tpoint.setLogInstant(instant);
- }
- }
- }
-
-
- /**
- Find a truncationLWM with the given name. If that
truncationLWM was
- never set or was removed, return null.
-
- <P>MT - MT safe. Whole routine is synchronized on this
- */
- public LogInstant getTruncationLWM(UUID name)
- {
- TruncationPoint tpoint;
- LogInstant instant = null;
-
- synchronized(this)
- {
- if ((tpoint = findTruncPoint(name)) != null)
- {
- instant = tpoint.getLogInstant();
-
- if (SanityManager.DEBUG)
- {
- LogCounter first = new
LogCounter(firstLogInstant());
- if (instant.lessThan(first))
- SanityManager.THROWASSERT(
- "truncation LWM " +
instant +
- " is < firstlog ( " +
first + ") !");
- }
- }
- // don't return from out of a sync block
- }
-
- return instant;
-
- }
-
-
- /**
- Remove a truncationLWM - logged
-
- <P>MT - MT aware: multiple threads can call removeTruncationLWM
if
- different LWMs are removed, but if multiple threads want to
remove the
- same LWM, an exception will be thrown.
-
- @exception StandardException if that truncationLWM cannot be
found.
- */
- public void removeTruncationLWM(UUID name,
-
RawStoreFactory rsf,
-
TransactionFactory tf)
- throws StandardException
- {
- if (SanityManager.DEBUG)
- SanityManager.ASSERT(name != null, "null UUID name");
-
- if (corrupt != null)
- {
- throw StandardException.newException(
- SQLState.LOG_STORE_CORRUPT, corrupt);
- }
-
- if (stopped)
- throw StandardException.newException(SQLState.LOG_FACTORY_STOPPED);
-
- synchronized(this)
- {
- if (findTruncPoint(name) == null)
- {
- throw StandardException.newException(
- SQLState.LOG_TRUNC_LWM_NULL);
- }
-
- // remove it now, only log it for persistence. Don't
wait till the
- // log is written out because I can't prevent 2 threads
from
- // removing the same LWM if they both go thru this
routine
- // simultaneously. Can't keep the log factory in
single thread for
- // so long.
-
- removeTruncationLWM(name);
- }
-
- Loggable lop = new SaveLWMOperation(name, null, false /* unset
*/);
- // start an interanl transaction to log this
- RawTransaction itran = tf.startInternalTransaction(rsf,
ContextService.getFactory().getCurrentContextManager());
- try
- {
- itran.logAndDo(lop);
- }
- finally
- {
- itran.commit();
- itran.close();
- }
- }
-
-
- /**
- Remove a truncationLWM - underneath a log record
- @exception StandardException Standard cloudscape exception
policy
- */
- public void removeTruncationLWM(UUID name)
- throws StandardException
- {
-
- if (corrupt != null)
- {
- throw StandardException.newException(
- SQLState.LOG_STORE_CORRUPT, corrupt);
- }
-
- // During run time, we are called inside a synchronized block.
- // During recovery redo, no log truncation is going to happen.
- // So no need to synchronize here.
-
- // if it has already been removed, don't bother with it.
- synchronized(this)
- {
- TruncationPoint tpoint = findTruncPoint(name);
- if (tpoint != null)
- truncPoints.removeElement(tpoint);
- }
- }
-
- /**
- Find a truncationLWM.
-
- <P>MT - MT unsafe. Caller must provide synchronization
- */
- private TruncationPoint findTruncPoint(UUID name)
- {
- if (truncPoints == null)
- return null;
-
- for (int i = truncPoints.size()-1; i >= 0; i--)
- {
- TruncationPoint tpoint =
(TruncationPoint)(truncPoints.elementAt(i));
- if (tpoint.isEqual(name))
- return tpoint;
- }
- return null;
- }
-
- /**
Open a forward scan of the transaction log.
<P> MT- read only
@@ -4190,42 +3804,7 @@
return new LogCounter(logFileNumber,lastFlush);
}
- /** restore/replace truncpoints using the passed in arrays
- Called during recovery, no need for synchronization
- */
- private LogInstant restoreTruncationLWMs(TruncationPoint[] tpoints)
- {
- if (truncPoints != null)
- truncPoints.removeAllElements();
- if (tpoints == null || tpoints.length == 0)
- return null;
-
- if (truncPoints == null)
- truncPoints = new Vector(tpoints.length, 1);
-
- LogInstant earliestLWM = null;
-
- for (int i = 0; i < tpoints.length; i++)
- {
- TruncationPoint t = tpoints[i];
-
- if (SanityManager.DEBUG)
- SanityManager.DEBUG(DBG_FLAG,
-
"Restoring tpoint " + t.getName() + " " + t.getLogInstant());
-
- // The tpoints come out of the checkpoint log record,
OK to just
- // stuff it into the truncation table because the
checkpoint log
- // record is never going to change it.
- truncPoints.addElement(t);
-
- if (earliestLWM == null ||
t.getLogInstant().lessThan(earliestLWM))
- earliestLWM = t.getLogInstant();
- }
- return earliestLWM;
- }
-
-
/**
* Backup restore - stop sending log record to the log stream
* @exception StandardException Standard Cloudscape error policy
Index: java/engine/org/apache/derby/impl/store/raw/log/D_LogToFile.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/log/D_LogToFile.java
(revision 55271)
+++ java/engine/org/apache/derby/impl/store/raw/log/D_LogToFile.java
(working copy)
@@ -41,20 +41,9 @@
r.append(" lastFlush(offset): "+ltf.lastFlush+"\n");
r.append(" logFileNumber: "+ltf.logFileNumber+"\n");
r.append(" firstLogFileNumber:
"+ltf.firstLogFileNumber+"\n");
- if (ltf.truncPoints == null)
- {
- r.append(" truncPoints: null\n");
- }
- else
- {
- for(Enumeration e=ltf.truncPoints.elements();
- e.hasMoreElements();)
- {
- Object tp = e.nextElement();
- r.append(" tp: "+
-
DiagnosticUtil.toDiagString(tp));
- }
- }
return r.toString();
}
}
+
+
+
Index: java/engine/org/apache/derby/impl/store/raw/RawStore.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/RawStore.java (revision 55271)
+++ java/engine/org/apache/derby/impl/store/raw/RawStore.java (working copy)
@@ -824,28 +824,6 @@
}
- /*
- * log truncation support
- */
- public LogInstant setTruncationLWM(UUID name, DatabaseInstant instant)
- throws StandardException
- {
- return logFactory.setTruncationLWM(name, (LogInstant)instant,
this, xactFactory);
- }
-
- public LogInstant getTruncationLWM(UUID name)
- throws StandardException
- {
- return logFactory.getTruncationLWM(name);
- }
-
- public void removeTruncationLWM(UUID name)
- throws StandardException
- {
- logFactory.removeTruncationLWM(name, this, xactFactory);
- }
-
-
public ScanHandle openFlushedScan(DatabaseInstant start, int
groupsIWant)
throws StandardException
{
Index: java/engine/org/apache/derby/iapi/services/io/StoredFormatIds.java
===================================================================
--- java/engine/org/apache/derby/iapi/services/io/StoredFormatIds.java
(revision 55271)
+++ java/engine/org/apache/derby/iapi/services/io/StoredFormatIds.java
(working copy)
@@ -1673,11 +1673,6 @@
public static final int LOGOP_SET_RESERVED_SPACE =
(MIN_ID_2 + 287);
- /* org.apache.derby.impl.store.raw.log.SaveLWMOperation */
- public static final int LOGOP_SAVE_LWM =
- (MIN_ID_2 + 114);
-
-
/* org.apache.derby.impl.store.raw.data.RemoveFileOperation */
public static final int LOGOP_REMOVE_FILE =
(MIN_ID_2 + 291);
Index: java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java
===================================================================
--- java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java
(revision 55271)
+++ java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java
(working copy)
@@ -109,70 +109,8 @@
*/
public void flush(LogInstant where) throws StandardException;
- /**
- @see RawStoreFactory#setTruncationLWM
- @param name - the name of the truncation low water mark.
- @param rawStoreFactory - the raw store
- @param dataFactory - the data factory
- @param transactionFactory - the transaction factory
-
- @return The exact instant to which this set the truncation low
- water mark.
-
- @exception StandardException StandardCloudscape error policy
- */
-
- public LogInstant setTruncationLWM(UUID name,
-
LogInstant instant,
-
RawStoreFactory rawStoreFactory,
-
TransactionFactory transFactory)
- throws StandardException;
-
/**
- Internal to RawStore, setting the truncationLWM below the log
-
- @param name - the name of the truncation low water mark.
- @exception StandardException cloudscape standard error policy
-
- */
- public void setTruncationLWM(UUID name, LogInstant instant)
- throws StandardException;
-
-
- /**
- Get back a truncation LWM
- @exception StandardException cloudscape standard error policy
- */
- public LogInstant getTruncationLWM(UUID name)
- throws StandardException;
-
- /**
- Remove a truncation LWM - logged
-
- @param name - the name of the truncation low water mark.
- @param rawStoreFactory - the raw store
- @param dataFactory - the data factory
- @param transactionFactory - the transaction factory
-
- @exception StandardException cloudscape standard error policy
- */
- void removeTruncationLWM(UUID name,
- RawStoreFactory
rawStoreFactory,
- TransactionFactory
transFactory)
- throws StandardException;
-
- /**
- Remove a truncation LWM - underneath the log
-
- @param name - the name of the truncation low water mark.
- @exception StandardException cloudscape standard error policy
- */
- void removeTruncationLWM(UUID name)
- throws StandardException;
-
-
- /**
Get a LogScan to scan flushed records from the log.
<P> MT- read only
Index: java/engine/org/apache/derby/iapi/store/raw/xact/RawTransaction.java
===================================================================
--- java/engine/org/apache/derby/iapi/store/raw/xact/RawTransaction.java
(revision 55271)
+++ java/engine/org/apache/derby/iapi/store/raw/xact/RawTransaction.java
(working copy)
@@ -272,22 +272,6 @@
/**
- Add a truncation LWM to the log factory
-
- @exception StandardException Standard Cloudscape error policy
- */
- public abstract void addTruncationLWM(UUID name, LogInstant instant)
- throws StandardException;
-
-
- /**
- Remove a truncation LWM from the log factory
- @exception StandardException Standard Cloudscape error policy
- */
- public abstract void removeTruncationLWM(UUID name) throws
StandardException;
-
-
- /**
Status that needs to go into the begin transaction log record,
if there
is one, to help with recovery
*/
Index: java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java
===================================================================
--- java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java
(revision 55271)
+++ java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java
(working copy)
@@ -710,63 +710,7 @@
*/
public void idle() throws StandardException;
- /*
- Log truncation support - only applies to rawStore that supports
logging
- and log truncation control.
-
- The RawStore will maintain a set of log instances called
truncation low
- water marks. These TruncationLWMs are identified by UUID.
Once set,
- the RawStore will not truncate any log record pass any
TruncationLWM.
- The client must reset these TruncationLWM or delete them from
RawStore
- or else the log will fill up.
-
- These TruncationLWMs are durable across crashes
- */
-
/**
- Set truncation low water mark. If instant is null, set this
named
- truncation LWM to be the earliest legal log instant currently
still
- available - i.e., the first log instant that has not been
truncated.
- If a truncation low water mark of this name does not exist this
creates
- it. If a truncation low water mark of this name already exists
then
- this call will move it to a new log instant.
- <P>
- When this returns the system will durably remember the new low
water
- mark.
-
- @param name The name of the new low water mark.
- @return The truncation low water mark log instant.
-
- @exception StandardException StandardCloudscape error policy
- */
- LogInstant setTruncationLWM(UUID name, DatabaseInstant instant)
- throws StandardException;
-
-
- /**
- Remove a truncation low water mark. An exception will be
thrown if it
- is not already set.
- <P>
- When this returns the low water mark is removed from the system
- permanently.
-
- @param name The name of the truncation low water mark.
-
- @exception StandardException StandardCloudscape error policy
- */
- void removeTruncationLWM(UUID name) throws StandardException;
-
- /**
- Get a truncatin low water mark. If it is not set, return null.
-
- @param name The name of the truncation low water mark.
-
- @exception StandardException StandardCloudscape error policy
- */
- LogInstant getTruncationLWM(UUID name) throws StandardException;
-
-
- /**
Get a flushed scan.
@param start The instant for the beginning of the scan.
@param groupsIWant log record groups the caller wants to scan.