[
https://issues.apache.org/jira/browse/LENS-1286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15490306#comment-15490306
]
Hudson commented on LENS-1286:
------------------------------
UNSTABLE: Integrated in Jenkins build Lens-Commit-Java8 #252 (See
[https://builds.apache.org/job/Lens-Commit-Java8/252/])
LENS-1286: Handle Restart cases for Scheduler (rajatgupta59: rev
3ab732accdfb19b87da0bf5c72e301b0c2a42b84)
* (edit)
lens-server/src/main/java/org/apache/lens/server/scheduler/SchedulerQueryEventListener.java
* (edit)
lens-server/src/main/java/org/apache/lens/server/scheduler/SchedulerServiceImpl.java
* (edit)
lens-server/src/test/java/org/apache/lens/server/scheduler/TestSchedulerServiceImpl.java
* (edit)
lens-server/src/test/java/org/apache/lens/server/scheduler/util/SchedulerTestUtils.java
* (add)
lens-server/src/test/java/org/apache/lens/server/scheduler/SchedulerRestartTest.java
* (edit)
lens-server/src/main/java/org/apache/lens/server/scheduler/SchedulerDAO.java
> Handle Lens server restart
> --------------------------
>
> Key: LENS-1286
> URL: https://issues.apache.org/jira/browse/LENS-1286
> Project: Apache Lens
> Issue Type: Sub-task
> Components: server
> Reporter: Lavkesh Lahngir
> Assignee: Lavkesh Lahngir
> Fix For: 2.7
>
> Attachments: restart.patch
>
>
> Scheduled events which are generated by AlarmService for scheduling are
> processed by a SchedulerEventListener thread.
> These steps are performed after receiving a scheduled event:
> 1. Get the job stored in the SchedulerDAO
> 2. Create a session with job owner and fill the session conf.
> 3. Create the instance if it is not a rerun otherwise get the instance from
> the store.
> 4. Create a Run instance.
> 5. Store instance (if not present) and run to the store.
> 6. Launch the query.
> 7. Update the run with the latest information.
> 8. If there is a failure in query launch then update the run status to be
> failed.
> While EventListener is processing the event, it can be closed during the
> shutdown of scheduler service. Closing the thread can cause operations to be
> incomplete.
> There are these stages where the thread can be interrupted:
> 1. Shutdown just after the alarm Event is fired and received:
> In this case, we won't have any entry for the instance run in the store. This
> will cause a hole in the list of instances.
> 2. Shutdown before query launch.
> In this case, at least we will have an entry in the table and status as NEW.
> 3. Shutdown after query launch.
> In this case, the status won't be updated, and even if the query is launched
> we will have no information about the handle. When this happens the
> scheduled status will remain NEW
> Of all the scenarios above, the first one is kind of annoying because there
> is no way to generate the event from Alarm Service again if it is already
> triggered.
> Second and third scenarios can be handled manually by killing the instance
> and re-running it.
> Apart from the scheduler event listener thread, we have another thread which
> processes the query end event which works as follows:
> 1. Receive the event and check if this is a scheduled query.
> 2. Check the final status of the query and set it as the instance status.
> If a shutdown happens after receiving the query end event, it will cause the
> status to remain as RUNNING.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)