Description
Issue Description
When utilizing Sqlite in-memory as a backend for Dapr Workflow, an issue arises where the application is executed immediately after the workflow is initiated. This results in the following error:
Unhandled exception. Dapr.DaprException: Start Workflow operation failed: the Dapr endpoint indicated a failure.
See InnerException for details.
---> Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="error starting workflow 'OrderProcessingWorkflow':
unable to start workflow: failed to start orchestration: backend not initialized")
Upon investigation, it was identified that the error is caused by a specific line in the Durable Task for Go library, where the initialization of the Sqlite database takes time. Consequently, when the application starts executing the workflow, it encounters an error due to Sqlite not being ready. Given some time (e.g., 10-15 seconds), the application is able to run the workflow successfully with the Sqlite backend.
Proposed Solution
To address this issue, it is suggested to implement a mechanism similar to the one found in the Actor backend. Specifically, exposing a method in the Backend interface to check whether the backend is ready or not. The proposed addition to the Backend interface is as follows:
type Backend interface {
...
...
WaitForBackendReady(context.Context)
}
This method will allow applications to wait until the Sqlite backend is fully initialized before attempting to execute workflows, preventing the encountered error.
Steps to Reproduce
- Set up Dapr Workflow with Sqlite in-memory as the backend.
- Initiate a workflow immediately after starting the application.
- Observe the error mentioned above.