Skip to content

Issue with Sqlite backend initialization in Dapr Workflow #49

Open
@ASHIQUEMD

Description

@ASHIQUEMD

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

  1. Set up Dapr Workflow with Sqlite in-memory as the backend.
  2. Initiate a workflow immediately after starting the application.
  3. Observe the error mentioned above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions