Adding new Logic/Activities to workflow(not modifying existing activities)

If I were to add a new piece of logic/activity - doSomething_C(request) to existing workflow code. Wondering if I need to do versioning like this. Refer: Versioning | Temporal Documentation

 val version = Workflow.getVersion("addActivity_C", Workflow.DEFAULT_VERSION, 1)
            if (version == Workflow.DEFAULT_VERSION) {
                doSomething_A(request) // calls an activity A
                doSomething_B(request) // calls an activity B
            } else {
                doSomething_A(request)
                doSomething_B(request)
                doSomething_C(request) // // calls an activity C
            }

or

 val version = Workflow.getVersion("addActivity_C", Workflow.DEFAULT_VERSION, 1)
                doSomething_A(request)
                doSomething_B(request)
              if (version != Workflow.DEFAULT_VERSION) {
                doSomething_C(request)
            }

Second example to me at least looks cleaner as it versions the intended change only. Both should work fine.

Thanks @tihomir . I understand versioning is to avoid non-determinism, especially when there are long running workflows with wait times or if workflow instances are in flight.
My workflow is just a short lived one, do you still recommend versioning it? if so, what would be the reason(s).

@workflow
do you have queryMethods in your workflow? if you execute a query against a closed workflow, the worker might need to replay the workflow history to recreate the workflow state before returning the value.

If you wait for all workflow executions to complete before deploying a new workflow version and you don’t have to interact with your closed workflows, I think you are safe.

@antonio.perez That is good to know. Thanks. We don’t use queryMethods, but we use temporal UI to search workflows by workflowId or name to see their history. Wondering if UI internally runs queryMethods and we may run into this issue if we don’t version. Am I right?

Hello @workflow

Searching in the UI and invoking a queryMethod are different things.

When you invoke a @queryMethod , a worker needs to recreate the workflow state before returning the value, because the value itself is not stored as a field/value anywhere. You need to have a worker running pulling the workflow taskqueue to run a querymethod, even if the workflow is not running.

When you search in the UI the query will run against the database or ES if you have enabled advanced visibility (Visibility | Temporal Documentation). The same happens when you use the skd to query workflow executions workflowServiceStubs.blockingStub().listWorkflowExecutions(listWorkflowExecutionRequest)

Is there any reason why you can not use versioning in your workflow?

This video from Tiho is a good resource to understand how versioning works in Temporal Move Fast WITHOUT Breaking Anything - Workflow Versioning with Temporal - YouTube

you can also have a look to :

That makes sense. We do use versioning. just wanted to know when it is not needed. Thanks for all the info.