[ 
https://issues.apache.org/jira/browse/NIFI-6226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bryan Rosander updated NIFI-6226:
---------------------------------
    Description: 
An EmptyRecordReader is returned when an EOF is encountered while reading the 
serialization name. [1]  EmptyRecordReader.getMaxEventId() returns 0 [2] which 
violates the RecordReader contract which specifies a -1 return when the reader 
has no records. [3]

This causes WriteAheadStorePartition to choose the file and its value (0) as 
the maximum event id, causing mass reindexing and potential id reuse. [4]

Suggest returning -1 from EmptyRecordReader.getMaxEventId()

 

Here's an example log entry when this issue manifests:
{code:java}
2019-04-17 20:30:20,153 INFO [pool-16-thread-1] 
o.a.n.p.store.WriteAheadStorePartition The last Provenance Event indexed for 
partition default is 53491, but the last event written to partition has ID 0. 
Re-indexing up to the last -53491 events to ensure that the Event Index is 
accurate and up-to-date
{code}
 

Repro:
 # Run NiFi to generate some provenance w/ write ahead repo
 # Shutdown NiFi
 # Create empty file in provenance dir w/ highest numeric value
 # Start NiFi

This has happened in real deploys where NiFi was killed before it could 
shutdown properly.

 

[1] 
[https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/RecordReaders.java#L134]

[2] 
[https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/EmptyRecordReader.java#L72]

[3] 
[https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/RecordReader.java#L112]

[4] 
[https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/WriteAheadStorePartition.java#L127]

  was:
An EmptyRecordReader is returned when an EOF is encountered while reading the 
serialization name. [1]  EmptyRecordReader.getMaxEventId() returns 0 [2] which 
violates the RecordReader contract which specifies a -1 return when the reader 
has no records. [3]

This causes WriteAheadStorePartition to choose the file and its value (0) as 
the maximum event id, causing mass reindexing and potential id reuse. [4]

Suggest returning -1 from EmptyRecordReader.getMaxEventId()

 

Here's an example log entry when this issue manifests:
{code:java}
2019-04-17 20:30:20,153 INFO [pool-16-thread-1] 
o.a.n.p.store.WriteAheadStorePartition The last Provenance Event indexed for 
partition default is 53491, but the last event written to partition has ID 0. 
Re-indexing up to the last -53491 events to ensure that the Event Index is 
accurate and up-to-date
{code}
 

Repro:
 # Run NiFi to generate some provenance w/ write ahead repo
 # Shutdown NiFi
 # Create empty file in provenance dir w/ highest numeric value
 # Start NiFi

We've seen this happen in real deploys where NiFi was killed before it could 
shutdown properly.

 

[1] 
[https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/RecordReaders.java#L134]

[2] 
[https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/EmptyRecordReader.java#L72]

[3] 
[https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/RecordReader.java#L112]

[4] 
[https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/WriteAheadStorePartition.java#L127]


> WriteAheadStorePartition thinks its maxEventId is 0 if empty or malformed 
> file w/ largest numeric name exists
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: NIFI-6226
>                 URL: https://issues.apache.org/jira/browse/NIFI-6226
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.8.0
>            Reporter: Bryan Rosander
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> An EmptyRecordReader is returned when an EOF is encountered while reading the 
> serialization name. [1]  EmptyRecordReader.getMaxEventId() returns 0 [2] 
> which violates the RecordReader contract which specifies a -1 return when the 
> reader has no records. [3]
> This causes WriteAheadStorePartition to choose the file and its value (0) as 
> the maximum event id, causing mass reindexing and potential id reuse. [4]
> Suggest returning -1 from EmptyRecordReader.getMaxEventId()
>  
> Here's an example log entry when this issue manifests:
> {code:java}
> 2019-04-17 20:30:20,153 INFO [pool-16-thread-1] 
> o.a.n.p.store.WriteAheadStorePartition The last Provenance Event indexed for 
> partition default is 53491, but the last event written to partition has ID 0. 
> Re-indexing up to the last -53491 events to ensure that the Event Index is 
> accurate and up-to-date
> {code}
>  
> Repro:
>  # Run NiFi to generate some provenance w/ write ahead repo
>  # Shutdown NiFi
>  # Create empty file in provenance dir w/ highest numeric value
>  # Start NiFi
> This has happened in real deploys where NiFi was killed before it could 
> shutdown properly.
>  
> [1] 
> [https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/RecordReaders.java#L134]
> [2] 
> [https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/EmptyRecordReader.java#L72]
> [3] 
> [https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/RecordReader.java#L112]
> [4] 
> [https://github.com/apache/nifi/blob/8411b6a46f5a2bf83eb3899cca3374bd863da1a0/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/WriteAheadStorePartition.java#L127]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to