Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logic app consumption | Service Bus trigger, waiting runs issue #1216

Open
mirzaciri opened this issue Oct 22, 2024 · 1 comment
Open

Logic app consumption | Service Bus trigger, waiting runs issue #1216

mirzaciri opened this issue Oct 22, 2024 · 1 comment
Labels

Comments

@mirzaciri
Copy link

mirzaciri commented Oct 22, 2024

Describe the Bug

For logic app consumption, using trigger "When a message is received in a topic subscription (peek-lock)", we see that some logic apps trigger "waiting runs", even though the max concurrency is set to a lower number.

Depending on how you save your logic app, even though the workflow JSON is the same, the logic app can behave differently.

Plan Type

Consumption

Steps to Reproduce the Bug or Issue

Doing testing and debugging, we see the following:

Test 1:

  1. Create Logic app A
  2. Add the service bus trigger (don't save yet)
  3. Change the Concurrency Control to 5
    Image
  4. Save (the first save after creating it).
  5. Batch send more than 5 messages (example 12).

You can see that 5 running processes and 7 waiting state logic apps will be triggered.
We don't like these 7 waiting state runs, because they are causing other issues with lock token and session id.

Test 2:

  1. Create logic app B
  2. Add the service bus trigger (don't save yet)
  3. Make sure that the Concurrency control, limit is off (default when creating).
  4. Image
  5. Save
  6. Go back to the logic app and change the Concurrency control to the same from test 1, limit on, Degree of parallelism 5.
  7. Save
  8. Batch send more than 5 messages (example 12).

Now you will see that only 5 running processes will be triggered, and only 5, no waiting processes. When one of them finishes, a new one starts. Make sure that only 5 running messages are running, and no in "waiting" state.

I want to point out that both logic app A and B, from the workflow JSON perspective, uses the same topic and sub, and the same service bus API connector, under the same resource group, location etc.

They are 100% the same, from the JSON view.
I want to make a very important note of what we tested:
If we copy the JSON logic app code between the logic apps A and B, we still see the issue on Logic app A, and not in Logic App B. Which is very strange.

Workflow JSON

{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Close_a_session_in_the_topic": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['servicebus']['connectionId']"
}
},
"method": "delete",
"path": "/@{encodeURIComponent(encodeURIComponent(parameters('topic')))}/subscriptions/@{encodeURIComponent(parameters('sub'))}/sessions/@{encodeURIComponent(triggerBody()?['SessionId'])}/close"
},
"runAfter": {
"Complete_the_message_in_a_topic_subscription": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Complete_the_message_in_a_topic_subscription": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['servicebus']['connectionId']"
}
},
"method": "delete",
"path": "/@{encodeURIComponent(encodeURIComponent(parameters('topic')))}/subscriptions/@{encodeURIComponent(parameters('sub'))}/messages/complete",
"queries": {
"lockToken": "@triggerBody()?['LockToken']",
"sessionId": "@triggerBody()?['SessionId']",
"subscriptionType": "Main"
}
},
"runAfter": {
"Renew_lock_on_the_session_in_a_topic_subscription-copy-copy": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Compose": {
"inputs": "@Body('Renew_lock_on_the_session_in_a_topic_subscription')",
"runAfter": {
"Renew_lock_on_the_session_in_a_topic_subscription": [
"Succeeded"
]
},
"type": "Compose"
},
"Delay": {
"inputs": {
"interval": {
"count": 1,
"unit": "Minute"
}
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "Wait"
},
"Renew_lock_on_the_session_in_a_topic_subscription": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['servicebus']['connectionId']"
}
},
"method": "post",
"path": "/@{encodeURIComponent(encodeURIComponent(parameters('topic')))}/subscriptions/@{encodeURIComponent(parameters('sub'))}/sessions/@{encodeURIComponent(triggerBody()?['SessionId'])}/renewlock"
},
"runAfter": {},
"type": "ApiConnection"
},
"Renew_lock_on_the_session_in_a_topic_subscription-copy": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['servicebus']['connectionId']"
}
},
"method": "post",
"path": "/@{encodeURIComponent(encodeURIComponent(parameters('topic')))}/subscriptions/@{encodeURIComponent(parameters('sub'))}/sessions/@{encodeURIComponent(triggerBody()?['SessionId'])}/renewlock"
},
"runAfter": {
"Delay": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Renew_lock_on_the_session_in_a_topic_subscription-copy-copy": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['servicebus']['connectionId']"
}
},
"method": "post",
"path": "/@{encodeURIComponent(encodeURIComponent(parameters('topic')))}/subscriptions/@{encodeURIComponent(parameters('sub'))}/sessions/@{encodeURIComponent(triggerBody()?['SessionId'])}/renewlock"
},
"runAfter": {
"Renew_lock_on_the_session_in_a_topic_subscription-copy": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
},
"sub": {
"defaultValue": "sub-name",
"type": "String"
},
"topic": {
"defaultValue": "topic-na,e",
"type": "String"
}
},
"triggers": {
"When_a_message_is_received_in_a_topic_subscription_(peek-lock)": {
"conditions": [],
"evaluatedRecurrence": {
"frequency": "Second",
"interval": 10
},
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['servicebus']['connectionId']"
}
},
"method": "get",
"path": "/@{encodeURIComponent(encodeURIComponent(parameters('topic')))}/subscriptions/@{encodeURIComponent(parameters('sub'))}/messages/head/peek",
"queries": {
"sessionId": "Next Available",
"subscriptionType": "Main"
}
},
"recurrence": {
"frequency": "Second",
"interval": 10
},
"runtimeConfiguration": {
"concurrency": {
"runs": 5
}
},
"type": "ApiConnection"
}
}
},
"parameters": {
"$connections": {
"value": {
"servicebus": {
"connectionId": "/subscriptions/x/resourceGroups/x/providers/Microsoft.Web/connections/servicebus",
"connectionName": "servicebus",
"id": "/subscriptions/x/providers/Microsoft.Web/locations/westeurope/managedApis/servicebus"
}
}
}
}
}

Screenshots or Videos

When we have waiting runs:
Image

When we don't:
Image

Additional context

No response

Copy link

github-actions bot commented Dec 6, 2024

This issue is stale because it has been open for 45 days with no activity.

@github-actions github-actions bot added the stale label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant