[ 
https://issues.apache.org/jira/browse/FLINK-10353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16673437#comment-16673437
 ] 

ASF GitHub Bot commented on FLINK-10353:
----------------------------------------

StefanRRichter opened a new pull request #7010: [FLINK-10353][kafka] Support 
change of transactional semantics in Kaf…
URL: https://github.com/apache/flink/pull/7010
 
 
   …ka Producer with existing state
   
   ## What is the purpose of the change
   
   This PR changes `FlinkKafkaProducer` and  `FlinkKafkaProducer011` to support 
a change of transactional semantics when restoring from existing state, e.g. a 
savepoint.
   
   ## Brief change log
   
   - Introduced `KafkaTransactionState#isTransactional` to distinguish which 
transactional handling should be applied instead of relying on what is 
currently configured.
   
   - Call `initializeUserContext` in `TwoPhaseCommitSinkFunction` for all cases 
that did not recover a user context.
   
   - Consider removing tranactional id from the properties when creating a new 
producer to deactivate transactional semantics if no longer required.
   
   
   ## Verifying this change
   
   Added `FlinkKafkaProducer(11)ITCase#testMigrateFromAtLeastOnceToExactlyOnce` 
and `#testMigrateFromAtExactlyOnceToAtLeastOnce`
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Restoring a KafkaProducer with Semantic.EXACTLY_ONCE from a savepoint written 
> with Semantic.AT_LEAST_ONCE fails with NPE
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-10353
>                 URL: https://issues.apache.org/jira/browse/FLINK-10353
>             Project: Flink
>          Issue Type: Improvement
>          Components: Kafka Connector
>    Affects Versions: 1.5.3, 1.6.0
>            Reporter: Konstantin Knauf
>            Priority: Critical
>              Labels: pull-request-available
>
> If a KafkaProducer with {{Semantic.EXACTLY_ONCE}} is restored from a 
> savepoint written with {{Semantic.AT_LEAST_ONCE}} the job fails on restore 
> with the NPE below. This makes it impossible to upgrade an AT_LEAST_ONCE 
> pipeline to an EXACTL_ONCE pipeline statefully.
> {quote}
> java.lang.NullPointerException
>       at java.util.Hashtable.put(Hashtable.java:460)
>       at 
> org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011.initTransactionalProducer(FlinkKafkaProducer011.java:955)
>       at 
> org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011.recoverAndCommit(FlinkKafkaProducer011.java:733)
>       at 
> org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011.recoverAndCommit(FlinkKafkaProducer011.java:93)
>       at 
> org.apache.flink.streaming.api.functions.sink.TwoPhaseCommitSinkFunction.recoverAndCommitInternal(TwoPhaseCommitSinkFunction.java:373)
>       at 
> org.apache.flink.streaming.api.functions.sink.TwoPhaseCommitSinkFunction.initializeState(TwoPhaseCommitSinkFunction.java:333)
>       at 
> org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011.initializeState(FlinkKafkaProducer011.java:867)
>       at 
> org.apache.flink.streaming.util.functions.StreamingFunctionUtils.tryRestoreFunction(StreamingFunctionUtils.java:178)
>       at 
> org.apache.flink.streaming.util.functions.StreamingFunctionUtils.restoreFunctionState(StreamingFunctionUtils.java:160)
>       at 
> org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.initializeState(AbstractUdfStreamOperator.java:96)
>       at 
> org.apache.flink.streaming.api.operators.AbstractStreamOperator.initializeState(AbstractStreamOperator.java:254)
>       at 
> org.apache.flink.streaming.runtime.tasks.StreamTask.initializeState(StreamTask.java:738)
>       at 
> org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:289)
>       at org.apache.flink.runtime.taskmanager.Task.run(Task.java:711)
>       at java.lang.Thread.run(Thread.java:748){quote}
> The reason is, that for {{Semantic.AT_LEAST_ONCE}} the snapshotted state of 
> the {{TwoPhaseCommitFunction}} is of the form 
> "TransactionHolder\{handle=KafkaTransactionState [transactionalId=null, 
> producerId=-1, epoch=-1], transactionStartTime=1537175471175}".



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

Reply via email to