Ferenc Gerlits created MINIFICPP-2291:
-----------------------------------------

             Summary: Site-to-site client should treat 
TRANSACTION_FINISHED_BUT_DESTINATION_FULL as (qualified) success
                 Key: MINIFICPP-2291
                 URL: https://issues.apache.org/jira/browse/MINIFICPP-2291
             Project: Apache NiFi MiNiFi C++
          Issue Type: Bug
            Reporter: Ferenc Gerlits
            Assignee: Ferenc Gerlits


Currently, the site-to-site client in MiNiFi only accepts 
{{TRANSACTION_FINISHED(13)}} as a success code, and it treats everything else 
as failure:

https://github.com/apache/nifi-minifi-cpp/blob/9e4ef8d59dbbe345c889edb2f3ed13c98513c96d/libminifi/src/sitetosite/SiteToSiteClient.cpp#L385
{code:c++}
if (code == TRANSACTION_FINISHED) {
  logger_->log_info("Site2Site transaction {} peer finished transaction", 
transactionID.to_string());
  transaction->_state = TRANSACTION_COMPLETED;
  return true;
} else {
  logger_->log_warn("Site2Site transaction {} peer unknown respond code {}", 
transactionID.to_string(), magic_enum::enum_underlying(code));
  return false;
}{code}

On the other hand, the NiFi site-to-site client treats both 
{{TRANSACTION_FINISHED(13)}} and 
{{TRANSACTION_FINISHED_BUT_DESTINATION_FULL(14)}} as success codes:

https://github.com/apache/nifi/blob/3fcf5f25b4c705f6909d058d81a7b8b6d6a648f1/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/protocol/http/StandardHttpFlowFileServerProtocol.java#L120
{code:java}
            switch (response) {
                case CONFIRM_TRANSACTION:
                    logger.debug("{} Confirming transaction. checksum={}", 
this, explanation);
                    commSession.setChecksum(explanation);
                    
commSession.setStatus(Transaction.TransactionState.DATA_EXCHANGED);
                    break;
                case TRANSACTION_FINISHED:
                case TRANSACTION_FINISHED_BUT_DESTINATION_FULL:
                    logger.debug("{} Transaction is completed. 
responseCode={}", this, response);
                    
commSession.setStatus(Transaction.TransactionState.TRANSACTION_COMPLETED);
                    break;
            }{code}

https://github.com/apache/nifi/blob/3fcf5f25b4c705f6909d058d81a7b8b6d6a648f1/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/protocol/AbstractFlowFileServerProtocol.java#L371
{code:java}
        logger.debug("{} received {} from {}", new Object[]{this, 
transactionResponse, peer});
        if (transactionResponse.getCode() == 
ResponseCode.TRANSACTION_FINISHED_BUT_DESTINATION_FULL) {
            peer.penalize(port.getIdentifier(), 
port.getYieldPeriod(TimeUnit.MILLISECONDS));
        } else if (transactionResponse.getCode() != 
ResponseCode.TRANSACTION_FINISHED) {
            throw new ProtocolException("After sending data, expected 
TRANSACTION_FINISHED response but got " + transactionResponse);
        }{code}

{{TRANSACTION_FINISHED_BUT_DESTINATION_FULL(14)}} can happen when the number or 
the total size of the files in the batch exceed the limits set in the Back 
Pressure settings of the outgoing connection of the input port on the server 
side.

MiNiFi should behave in the same way as NiFi: accept 
{{TRANSACTION_FINISHED_BUT_DESTINATION_FULL(14)}} as success, but the remote 
processor group should yield, so the server has time to clear the connection.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to