[
https://issues.apache.org/jira/browse/FLINK-39989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150369#comment-18150369
]
Filippo Ghibellini commented on FLINK-39989:
--------------------------------------------
After revisiting the problem I got the impression the main source of our
trouble is that `ArchivedApplicationStore` is currently a process-bound storage
which doesn't seem to make sense given that the job is a distributed entity.
What if we provide a distributed implementation that mirrors the behavior of
all other storages used in the HA setup? The basic idea is sketched out in the
following implementation:
[https://github.com/fghibellini/flink/blob/92fa728ca2a1888dfb798a4bafa5608bfca73fbf/flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/StateHandleArchivedApplicationStore.java]
The new implementation can be enabled by setting
{code:java}
completed-application-store.type: HA{code}
and it will write archivedApplication entries to the k8s config map (reads are
still fast as all entries are cached in memory).
I have tested its behavior in a minikube setup and can confirm that the
archived applications are restored on job manager recovery and thus it solves
the problem of the k8s operator getting stuck due to the "job not found" error.
The obvious downside is the temporary accumulation of terminated jobs in the
k8s configmap. All k8s configmaps are restricted to 1MiB of data so it's pretty
expensive real-estate.
Several things could be improved (e.g., reusing Guava's Cache doesn't seem
ideal here, but it simplified providing a basic prototype) and I haven't
explored the ZooKeeper aspect of things much, but {*}I avoided spending too
much time polishing the PR in case the approach was deemed undesirable{*}.
Complete diff:
[https://github.com/apache/flink/compare/c38964f306b05496ddb27385f13fcdf13374e1bc...fghibellini:flink:92fa728ca2a1888dfb798a4bafa5608bfca73fbf]
> flinksessionjob stuck on "Job Not Found" if jobmanager terminates before
> operator learns about new job state transitions
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: FLINK-39989
> URL: https://issues.apache.org/jira/browse/FLINK-39989
> Project: Flink
> Issue Type: Bug
> Components: Kubernetes Operator
> Affects Versions: 1.13
> Environment: * Flink version: 2.1.2
> * Flink Kubernetes operator version: 1.13
> Reporter: Filippo Ghibellini
> Priority: Major
>
> h3. Steps to reproduce
> # create a `flinksessionjob` and wait for it to start running
> # scale down the k8s operator to 0 replicas to simulate a delayed
> reconciliation
> # use the Flink web UI to cancel the job (or use any other method to put the
> job in a [globally terminal
> state|https://nightlies.apache.org/flink/flink-docs-stable/docs/internals/job_scheduling/#jobmanager-data-structures])
> # delete all the job manager pods (will be replaced automatically by the k8s
> deployment)
> # scale the k8s operator back to 1 replica - this will resume the
> reconciliation process
> # The `flinksessionjob` k8s entity now reports `Job Not Found`
> It seems that the entire reconciliation process relies heavily on the k8s
> operator learning about job terminations from the job-manager {*}before the
> job-manager restarts{*}.
> A newly started job-manager will not recover jobs that reached a "globally
> terminal state" (since those are not even persisted in the HA state).
> In our case it seems like the trigger for the jobs reaching a globally
> terminal state was us setting `spec.job.state=suspended` on the k8s
> `flinksessionjob` entity i.e. even though in the reproduction steps we cancel
> the job through the UI, the problem can manifest even if the Flink cluster is
> managed exclusively through the k8s operator (it's just harder to reproduce).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)