mirror of https://github.com/apache/activemq.git
Avoid deleting datafiles that are in-use.. timing issue was making this possible
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@588725 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6084b6061b
commit
3a4a360d3f
|
@ -374,9 +374,20 @@ public final class AsyncDataManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void consolidateDataFilesNotIn(Set<Integer> inUse) throws IOException {
|
public synchronized void consolidateDataFilesNotIn(Set<Integer> inUse, Integer lastDataFile) throws IOException {
|
||||||
Set<Integer> unUsed = new HashSet<Integer>(fileMap.keySet());
|
Set<Integer> unUsed = new HashSet<Integer>(fileMap.keySet());
|
||||||
unUsed.removeAll(inUse);
|
unUsed.removeAll(inUse);
|
||||||
|
|
||||||
|
// Don't purge any data files past lastDataFile
|
||||||
|
if( lastDataFile!=null ) {
|
||||||
|
for (Iterator iterator = unUsed.iterator(); iterator.hasNext();) {
|
||||||
|
DataFile dataFile = (DataFile)iterator.next();
|
||||||
|
if( dataFile.getDataFileId() >= lastDataFile ) {
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<DataFile> purgeList = new ArrayList<DataFile>();
|
List<DataFile> purgeList = new ArrayList<DataFile>();
|
||||||
for (Integer key : unUsed) {
|
for (Integer key : unUsed) {
|
||||||
DataFile dataFile = (DataFile)fileMap.get(key);
|
DataFile dataFile = (DataFile)fileMap.get(key);
|
||||||
|
@ -581,4 +592,10 @@ public final class AsyncDataManager {
|
||||||
this.useNio = useNio;
|
this.useNio = useNio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
synchronized public Integer getCurrentDataFileId() {
|
||||||
|
if( currentWriteFile==null )
|
||||||
|
return null;
|
||||||
|
return currentWriteFile.getDataFileId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,8 +351,11 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
|
||||||
*/
|
*/
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
try {
|
try {
|
||||||
|
// Capture the lastDataFile so that we don't delete any data files
|
||||||
|
// after this one.
|
||||||
|
Integer lastDataFile = asyncDataManager.getCurrentDataFileId();
|
||||||
Set<Integer> inUse = referenceStoreAdapter.getReferenceFileIdsInUse();
|
Set<Integer> inUse = referenceStoreAdapter.getReferenceFileIdsInUse();
|
||||||
asyncDataManager.consolidateDataFilesNotIn(inUse);
|
asyncDataManager.consolidateDataFilesNotIn(inUse, lastDataFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Could not cleanup data files: " + e, e);
|
LOG.error("Could not cleanup data files: " + e, e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue