Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-8727

claimantCount will never decrement to zero

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.12.0, 1.13.0, 1.12.1, 1.13.1, 1.13.2
    • 1.15.0
    • Core Framework
    • None
    • linux
    • Important

    Description

      When running my processor code below :

      //originalFlowFile has content , so ClaimantCount=1
       FlowFile multiFlowFile = session.clone(originalFlowFile); // claim count +1,so ClaimantCount=2
       multiFlowFile = session.write(multiFlowFile, new OutputStreamCallback() {
           @Override
           public void process(OutputStream out) throws IOException {
              IOUtils.write(tvMultiAlbumJson, out, Charset.forName("UTF-8"));
           }
       });//the new content will resuse the same resource claim , so ClaimantCount=3
       //At this point we have two flowfile and two contentClaim ,and ClaimCount=3.
       //When this two flowfiles dropped,the claimantCount should decrement to 0,however the result is ClaimantCount=1!
       //If we use "sh nifi.sh diagnostics --verbose dump.log" to get a dump log,we will find some info like thisdefault/465/1623853427574-10705, Claimant Count = 1, In Use = true, Awaiting Destruction = false, References (0) = []” 
       //And the file “default/465/1623853427574-10705” will never be archived,and will never be destroyed,and the content_repository will use more storage than it configs.

      The above is a sort of phenomenon. The reason is the code below:

      //session.clone
       public FlowFile clone(FlowFile example, final long offset, final long size) {
           .....................................
           final StandardRepositoryRecord record = new StandardRepositoryRecord(null); //here the originalFlowFileRecord of record is null
           .....................................
           return clone;
       }
       //session.commit
       private void updateClaimCounts(final RepositoryRecord record) {
           ..........................................................
           if (record.isContentModified()) {
           decrementClaimCount(originalClaim); //here the originalClaim is null
           }
       }

      Perhaps we should not use session.clone like that,but without official note it will sometimes happen to be used.
      So i change "final StandardRepositoryRecord record = new StandardRepositoryRecord(null)" to "final StandardRepositoryRecord record = new StandardRepositoryRecord(null, currRec);"

       

       

      Attachments

        There are no Sub-Tasks for this issue.

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            markbean Mark Bean
            wildq wangliqiang
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 192h
              192h
              Remaining:
              Time Spent - 2h 50m Remaining Estimate - 189h 10m
              189h 10m
              Logged:
              Time Spent - 2h 50m Remaining Estimate - 189h 10m
              2h 50m

              Issue deployment