Management of Mutex Workflow

Hi,
I’m looking into the possibility of using a mutex in order to lock/unlock a shared resource in a namespace.
In particular considering the code here https://github.com/temporalio/go-samples/blob/master/mutex/mutex_workflow.go
I have some doubts:

  1. What do you mean for namespace? It seems a simple label
  2. The “MutexWorkflow”, that should be able to synchronize requests, receives the parameter “namespace” but does not use it.
  3. As I understand, the Workflow “MutexWorkflow” run in single instance (we have a single worker) but what happens if the application is scaled and we have multiple worker? In this case the “MutexWorkflow” will be registered on multiple nodes.
  4. there is a particular reason for using SignalWithStartMutexWorkflowActivity as LocalActivity? What if it is a simple Activity?
    Thanks
  1. I assume that namespace is related to the temporal namespace (it was called domain in Cadence)
  2. Good catch! It looks like during the latest refactoring the namespace indeed became orphaned. I’m going to remove it from the code as it is not really needed.
  3. Don’t confuse workflow executions (instances) and workers. Workflow execution is identified by a unique WorkflowId and is not linked to any specific worker instance. Otherwise, it would be impossible to guarantee fault tolerance of the workflow code in the presence of worker restarts and redeployments. Workflow type registration with a worker is just an association of a function that should be invoked when a worker receives requests for the given workflow. It is purely local to a specific worker process.
  4. No particular reason. It would work fine with normal activity. Local activities are a very useful optimization for some high throughput use cases, but I would avoid unless you have a pretty deep understanding of the system as they have some non-obvious edge cases.

Great Thanks for your reply. This is very useful.