mirror of https://github.com/apache/nifi.git
NIFI-7346: Ensure that the Provenance Repository doesn't delete the Active Event File
This commit is contained in:
parent
728bdec0f4
commit
c99a187018
|
@ -481,6 +481,10 @@ public class WriteAheadStorePartition implements EventStorePartition {
|
||||||
.forEach(this::delete);
|
.forEach(this::delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File getActiveEventFile() {
|
||||||
|
final RecordWriterLease lease = eventWriterLeaseRef.get();
|
||||||
|
return lease == null ? null : lease.getWriter().getFile();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long purgeOldestEvents() {
|
public long purgeOldestEvents() {
|
||||||
|
@ -489,8 +493,7 @@ public class WriteAheadStorePartition implements EventStorePartition {
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
final RecordWriterLease lease = eventWriterLeaseRef.get();
|
final File currentFile = getActiveEventFile();
|
||||||
final File currentFile = lease == null ? null : lease.getWriter().getFile();
|
|
||||||
for (final File eventFile : eventFiles) {
|
for (final File eventFile : eventFiles) {
|
||||||
if (eventFile.equals(currentFile)) {
|
if (eventFile.equals(currentFile)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -511,6 +514,12 @@ public class WriteAheadStorePartition implements EventStorePartition {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean delete(final File file) {
|
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);
|
final long firstEventId = DirectoryUtils.getMinId(file);
|
||||||
synchronized (minEventIdToPathMap) {
|
synchronized (minEventIdToPathMap) {
|
||||||
minEventIdToPathMap.remove(firstEventId);
|
minEventIdToPathMap.remove(firstEventId);
|
||||||
|
|
Loading…
Reference in New Issue