NIFI-7346: Ensure that the Provenance Repository doesn't delete the Active Event File

This commit is contained in:
Mark Payne 2020-04-09 09:09:43 -04:00 committed by Bryan Bende
parent 728bdec0f4
commit c99a187018
1 changed files with 11 additions and 2 deletions

View File

@ -481,6 +481,10 @@ public class WriteAheadStorePartition implements EventStorePartition {
.forEach(this::delete);
}
private File getActiveEventFile() {
final RecordWriterLease lease = eventWriterLeaseRef.get();
return lease == null ? null : lease.getWriter().getFile();
}
@Override
public long purgeOldestEvents() {
@ -489,8 +493,7 @@ public class WriteAheadStorePartition implements EventStorePartition {
return 0L;
}
final RecordWriterLease lease = eventWriterLeaseRef.get();
final File currentFile = lease == null ? null : lease.getWriter().getFile();
final File currentFile = getActiveEventFile();
for (final File eventFile : eventFiles) {
if (eventFile.equals(currentFile)) {
continue;
@ -511,6 +514,12 @@ public class WriteAheadStorePartition implements EventStorePartition {
}
private boolean delete(final File file) {
final File activeEventFile = getActiveEventFile();
if (file.equals(activeEventFile)) {
logger.debug("Attempting to age off Active Event File {}. Will return without deleting the file.", file);
return false;
}
final long firstEventId = DirectoryUtils.getMinId(file);
synchronized (minEventIdToPathMap) {
minEventIdToPathMap.remove(firstEventId);