mysql timeoutSeconds and responseTimeoutSeconds are not working
The same works with REDIS and doesn't work with mysql. Did any one encounter this issue?
You can recreate the issue as below
Task and Workflow definations
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://localhost:8080/api/metadata/taskdefs' -d '
[{
"name": "T1",
"retryCount": 1,
"timeoutSeconds": 60,
"inputKeys": [
"sourceRequestId",
"qcElementType"
],
"outputKeys": [
"state",
"skipped",
"result"
],
"timeoutPolicy": "TIME_OUT_WF",
"retryLogic": "FIXED",
"retryDelaySeconds": 30,
"responseTimeoutSeconds": 60
}]
'
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://localhost:8080/api/metadata/workflow' -d '
[{
"name": "sample",
"description": "sample workflow",
"version": 1,
"tasks": [
{
"name": "T1",
"taskReferenceName": "T1",
"type": "SIMPLE",
"inputParameters": {
"fileName": "${workflow.input.fileName}"
}
}
],
"outputParameters": {
},
"schemaVersion": 2
}]
'
Workflow Instance
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' 'http://localhost:8080/api/workflow' -d '
{
"name": "sample",
"version": 1,
"correlatonId": "corr1",
"input": {
"fileName": "f1"
}
}
'
Call this URL curl -X GET --header 'Accept: application/json' 'http://localhost:8080/api/tasks/poll/T1'
wait for 2 mins, you will see the task is in_progress. Repeat the same with REDIS and backend and the task will go into time_out status after 2 mins.
It apparently looks like a bug to me in mysql.
Hi @mashurex and @picaron Any pointers on this issue. I just realized it. Are you have the same problem?
https://github.com/Netflix/conductor/blob/b8fa64ba8a0735192e56c06a790dbf193d600171/core/src/main/java/com/netflix/conductor/core/execution/WorkflowSweeper.java#L74-L96
List
Once the pop is called, it changes the value in queue_message popped value to "1". that's it. It is never reset back to "0" if the client does't process the task.
I am not sure if my assumption is correct. Want to here from you before I drill down into this path.
@jvemugunta I'll dive in and take a look later today.
So here's generally what happens with the queue daos
- Messages get put on the queue with an ACK timeout value
- Messages get popped when workers poll for them, MySQL queue DAO sets
popped = 1so we can un-pop them at a later time if need be - Workers will ACK the tasks as they get them, which in the case of the MySQL queue DAO will delete the row
- If Workers do not ACK the task in a certain amount of time, the messages that were popped should re-appear in the queue, this simply sets
popped = 0so it reappears the next time messages are peeked/popped QueueDAO::processUnacksis the method that will evaluate all popped messages for tasks that need to be un-popped, but this method does not get called regularly by any external sweeper code
Why does the Redis QueueDAO work correctly? It has internally configured a thread pool for calling its unack processing on a regular interval, check the RedisDynoQueueDAO constructor.
The fix for MySqlQueueDAO is pretty much the same as the implementation in RedisDynoQueueDAO and it should be posted in a bit.
@mashurex . The problem is bigger that what we think. There are some serious bugs. I have created an integration test with your code. MYSQL code is failing for 6 testcases as of now. I will find more and I digging more into the code. we have to redesign some of mysql tables.
Please run this class and make sure you have a local mysql DB running.
conductor/test-harness/src/test/java/com/netflix/conductor/tests/integration/WorkflowServiceMySQLTest.java

That’s interesting because I ran all tests before I created the PR... will look into this further. Also, I do agree that the tables may need re-work.
@jvemugunta When I run the test harness I get the same failures. I'm digging into the test workflow to figure out what the expectations mean and compare to the redis/dyno implementations.
@mashurex I am also looking into it. MYSQL has some bugs which could have been overlooked in the past. Some of them are very corner cases. We initially found these bugs during the performance testing. Later, I have realized all of the test harness with all edge cases were done with RedisMock.
When I enabled the same testing with mysql modules, all kinds of issues got surfaced and opened can of worms. We need to look at each of the Mysql DAO classes and compare line by line with RedisDAOs.
Our goal should getting the same functional behavior between REDIS and MySQL. Once functionality is matched, we should look at the performance numbers.
Let me know if you agree my thought process.
@jvemugunta @mashurex I am following your discussions about mysql issues. I am using sqlserver database as back-end to work with conductor with mysql module. I just modified mysql queries to work with sqlserver databse.
Still now we didn't do any performance test, but basic workflow execution testing is done, it looks good. Are there any major issues, if I want to move take this code to production?
May I know existing functional behavior difference between REDIS and MySQL.
There are some functionality bugs with MySQL DAOs. I am digging deep into the codebases and comparing MYSQL queries with Redis queries
I don’t have good answer as of now. I will publish my findings in the next few days
Sent from my iPhone
On Sep 9, 2018, at 1:36 PM, Samba [email protected] wrote:
@jvemugunta @mashurex I am following your discussions about mysql issues. I am using sqlserver database as back-end to work with conductor with mysql module. I just modified mysql queries to work with sqlserver databse.
Still now we didn't do any performance test, but basic workflow execution testing is done, it looks good. Are there any major issues, if I want to move take this code to production?
May I know existing functional behavior difference between REDIS and MySQL.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
I believe I've found the root cause... the task_scheduled table has a column called task_key and the task_key value was being generated in two different ways.
There are two methods that use task keys in the MySQLExecutionDao, MySQLExecutionDao::createTasks and MySQLExecutionDao::removeTask.
One of them was generating a task key as task.getReferenceTaskName() + "_" + task.getRetryCount() and the other was doing it as task.getReferenceTaskName() + "" + task.getRetryCount().
This means that when tasks are removed, they are not getting removed from the task_scheduled table, which was being caught during the test harness testWorkflowRerunWithSubWorkflows test. This bug would (probably) only present itself during rewinds and restarts, workflows that finish or fail would be generally unaffected.
After I fixed that all the test harness tests pass, which I'll include in my currently open PR.
@mashurex
Still these test cases are failing
testRetryWithForkJoin throws the below error
java.util.concurrent.ExecutionException: java.lang.RuntimeException: com.netflix.conductor.core.execution.ApplicationException: BACKEND_ERROR - Duplicate entry '5cc2e480-216d-4090-9982-d6883c0ec997-t4_0' for key 'unique_workflow_id_task_key'
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at com.netflix.conductor.tests.integration.MySQLWorkflowServiceTest.testRetryWithForkJoin(MySQLWorkflowServiceTest.java:2704)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:110)
at org.junit.rules.RunRules.evaluate(RunRules.java:18)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.RuntimeException: com.netflix.conductor.core.execution.ApplicationException: BACKEND_ERROR - Duplicate entry '5cc2e480-216d-4090-9982-d6883c0ec997-t4_0' for key 'unique_workflow_id_task_key'
at com.netflix.conductor.tests.integration.MySQLWorkflowServiceTest.lambda$45(MySQLWorkflowServiceTest.java:2691)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.netflix.conductor.core.execution.ApplicationException: BACKEND_ERROR - Duplicate entry '5cc2e480-216d-4090-9982-d6883c0ec997-t4_0' for key 'unique_workflow_id_task_key'
at com.netflix.conductor.dao.mysql.MySQLBaseDAO.getWithTransaction(MySQLBaseDAO.java:99)
at com.netflix.conductor.dao.mysql.MySQLBaseDAO.withTransaction(MySQLBaseDAO.java:121)
at com.netflix.conductor.dao.mysql.MySQLExecutionDAO.createTasks(MySQLExecutionDAO.java:101)
at com.netflix.conductor.core.execution.WorkflowExecutor.scheduleTask(WorkflowExecutor.java:842)
at com.netflix.conductor.core.execution.WorkflowExecutor.decide(WorkflowExecutor.java:599)
at com.netflix.conductor.core.execution.WorkflowExecutor.decide(WorkflowExecutor.java:608)
at com.netflix.conductor.core.execution.WorkflowExecutor.updateTask(WorkflowExecutor.java:528)
at com.netflix.conductor.service.ExecutionService.updateTask(ExecutionService.java:188)
at com.netflix.conductor.service.ExecutionService.updateTask(ExecutionService.java:184)
at com.netflix.conductor.tests.integration.MySQLWorkflowServiceTest.lambda$45(MySQLWorkflowServiceTest.java:2689)
... 5 more
Caused by: com.netflix.conductor.core.execution.ApplicationException: Duplicate entry '5cc2e480-216d-4090-9982-d6883c0ec997-t4_0' for key 'unique_workflow_id_task_key'
at com.netflix.conductor.dao.mysql.Query.executeUpdate(Query.java:274)
at com.netflix.conductor.dao.mysql.MySQLExecutionDAO.lambda$48(MySQLExecutionDAO.java:660)
at com.netflix.conductor.dao.mysql.MySQLBaseDAO.execute(MySQLBaseDAO.java:166)
at com.netflix.conductor.dao.mysql.MySQLExecutionDAO.addScheduledTask(MySQLExecutionDAO.java:659)
at com.netflix.conductor.dao.mysql.MySQLExecutionDAO.lambda$1(MySQLExecutionDAO.java:109)
at com.netflix.conductor.dao.mysql.MySQLBaseDAO.lambda$4(MySQLBaseDAO.java:122)
at com.netflix.conductor.dao.mysql.MySQLBaseDAO.getWithTransaction(MySQLBaseDAO.java:94)
... 14 more
There are concurrency issues with the tests, I found the ones that fail all pass correctly when run by themselves. If you read through them you’ll see they make certain expectations that assume they have the queue all to themselves. If you run them individually all pass.
And in fact, the same tests fail for me with the default modules as well.
Hi @mashurex . Thanks for spending time on this one . Yes, agreed. These are concurrency issues with MYSQL. However, the same tests passes with default REDIS modules.
This leaves me with few questions - There are race conditions that we present in REDIS and is being ignored because the REDIS database is not running in transactional mode.
However, the same got surface with MYSQL as we run in transactional mode. I guess we need why we are seeing concurrency issues and this bug with the product as a whole.
Can you send me your personal info to my email [email protected]? I want to discuss with few options on how to take this forward.
@mashurex . is this an issue ? Please review and let me know what you think
Class Name : MySQLExecutionDAO
method Name : getPendingTasksByWorkflow
String GET_IN_PROGRESS_TASKS_FOR_WORKFLOW = "SELECT json_data FROM task_in_progress tip "
+ "INNER JOIN task t ON t.task_id = tip.task_id " + "WHERE task_def_name = ? AND workflow_id = ?";
should be
String GET_IN_PROGRESS_TASKS_FOR_WORKFLOW = "SELECT json_data FROM task_in_progress tip "
+ "INNER JOIN task t ON t.task_id = tip.task_id " + "WHERE task_def_name = ? AND workflow_id = ? AND in_progress_status = true";
method Name : getPendingTasksForTaskType
String GET_IN_PROGRESS_TASKS_FOR_TYPE = "SELECT json_data FROM task_in_progress tip "
+ "INNER JOIN task t ON t.task_id = tip.task_id " + "WHERE task_def_name = ?";
should be
String GET_IN_PROGRESS_TASKS_FOR_TYPE = "SELECT json_data FROM task_in_progress tip " + "INNER JOIN task t ON t.task_id = tip.task_id " + "WHERE task_def_name = ? AND in_progress_status = true";
method Name : removeTaskInProgress
String REMOVE_IN_PROGRESS_TASK = "DELETE FROM task_in_progress WHERE task_def_name = ? AND task_id = ?";
should be
String REMOVE_IN_PROGRESS_TASK = "DELETE FROM task_in_progress WHERE task_def_name = ? AND task_id = ? and in_progress_status = true";
@gsambasiva
Still now we didn't do any performance test, but basic workflow execution testing is done, it looks good. Are there any major issues, if I want to move take this code to production? May I know existing functional behavior difference between REDIS and MySQL.
We've currently got a PR (actually, two) that will address some performance issues that @jvemugunta has worked diligently to diagnose and fix. If you look at pull requests #757 and #771 you'll see that chatter there.
I've integrated the MySQL module into the overall workflow test harness and it passes the exact same validations that the Redis module passes, so in general, I would say that MySQL persistence is tested in the same way that the Redis modules are and that they return the data like-for-like.
The issue is that we have to rely on the tests and test harnesses to prove this and there could be some cases (as found in this issue) where the MySQL module does not do what the Redis module does, or does it incorrectly.
I use the MySQL module in production in a low concurrency environment, I'm not sure if @jvemugunta is using in production, but I would believe that he's using it in a busier environment than we have been for the past few years.
@gsambasiva , We have moved to production recently. However, we want to use Netrflix Conductor at large scale in our enterprise.
Few things are being done
-
Regression tests are being added for MYSQL to match REDIS. I have identified some major defects with MYSQL code in terms of race conditions and functionality. As mentioned by @mashurex , all of the defects are addressed and you can follow my PR #771 for all of the bugs
-
Performance Testing : We are using Jmeter to bench mark performance testing, the performance looks good with 100 concurrent users on simple and complex workflow running for many hours.
-
One thing I am concerned about MYSQL is around the design of queue_message table and all of worker polls of conductor relies on this table. I am not comfortable about the design of this table. I need to dig deep on conductor and dyno queues before I propose a new design.I will work with @mashurex in the coming days on the design of this table. If we design this table right, MYSQL may perform even better than REDIS. Stay tuned and will send updates
Closing this issue as the relevant PRs have been merged and the fixes have been applied. Thanks @jvemugunta , @mashurex and @gsambasiva for your contributions.