Giter VIP home page Giter VIP logo

Comments (9)

cgillum avatar cgillum commented on June 3, 2024 2

@kaibocai I'm just now looking at the code you linked to, and I think you're correct about what the problem is. However, I disagree about the solution. There's nothing the extension can do to fix this - it merely persists the actions provided to it by the SDK. Rather, the problem in my opinion is that the SDK implementation is incorrect - we should not be blocking the orchestration like we are in the line you pointed to. The createTimer method needs to be reimplemented in a way that is non-blocking.

from durabletask-java.

kaibocai avatar kaibocai commented on June 3, 2024 1

I think the issue comes from here

createInstantTimer(this.sequenceNumber++, nextFireAt).await();

We explicitly await the internal timer to complete. So when customer have a timer larger than 3 days they will have an internal timer we set for them, and the code is waiting on this timer to complete first. In this case, all the external events are buffered in queue because the internal timer is not completed so no further action is taken on those events. This also explain why when timer smaller than 3 days we don't see this issue.

We may need to find another way to resolve issue rasied at #114

cc @cgillum @lilyjma

from durabletask-java.

kamperiadis avatar kamperiadis commented on June 3, 2024 1

@kanupriya15025 We just released SDK v1.4.0, which has the fix for this issue. You can find it here Central Repository: com/microsoft/durabletask-azure-functions/1.4.0 (apache.org) Thank you

from durabletask-java.

kanupriya15025 avatar kanupriya15025 commented on June 3, 2024

I have a feeling that this is related to this change :
https://github.com/kamperiadis/durabletask-java/blob/5b0c54de018c62f1fbb6746ef10c6731073c4148/client/src/main/java/com/microsoft/durabletask/DurableTaskGrpcWorker.java#L26

from durabletask-java.

kaibocai avatar kaibocai commented on June 3, 2024

Adding @kamperiadis for awareness.

from durabletask-java.

kamperiadis avatar kamperiadis commented on June 3, 2024

Thank you @kanupriya15025 for reporting this issue. Can you please clarify for me what you meant by "the event is read and then discarded." Just making sure that I understand the issue at hand - so you expected the "Patch received before start of schedule." to be shown since the patchEvent completed before the timer but you only saw the log when the timer was less than 3 days. Am I understanding it correctly?

from durabletask-java.

kamperiadis avatar kamperiadis commented on June 3, 2024

From my own testing, this seems to be happening because the orchestration does not finish starting before the external event is triggered. I was able to reproduce this issue when the timer had relatively large values since that's when I notice the orchestration taking longer to start. However, when I tested with a timer of 7 days, I still got the expected behavior, so I do not think this is related to the changes in #122 (i.e. 3 days did not consistently become the constraint for me). When testing with larger numbers (e.g. 10, 15), I was able to reproduce the issue more consistently.

from durabletask-java.

kamperiadis avatar kamperiadis commented on June 3, 2024

Hi @kanupriya15025! I was unable to reproduce this issue by following these steps:

  1. Make an API call to start the orchestration
  2. Wait for the orchestration to start
  3. Trigger the external event before the timer was up
  4. See the "winner is the external event" message in the logs

This is the sample code I am running

Endpoint that will trigger the orchestration:

    @FunctionName("StartOrchestration")
    public HttpResponseMessage startOrchestration(
        @HttpTrigger(name = "req",
                methods = {HttpMethod.GET, HttpMethod.POST},
                authLevel = AuthorizationLevel.ANONYMOUS) final HttpRequestMessage<Optional<String>> request,
        @DurableClientInput(name = "durableContext") final DurableClientContext durableContext,
        final ExecutionContext context) {
        context.getLogger().info("Java HTTP trigger processed a request");

        final DurableTaskClient client = durableContext.getClient();
        final String instanceId = client.scheduleNewOrchestrationInstance("WaitForExternalEvent");
        return durableContext.createCheckStatusResponse(request, instanceId);
    }

Orchestration logic similar to what you have described:

        Task<Something> event = ctx.waitForExternalEvent("Approval", Something.class);
        Task<?> timer = ctx.createTimer(Duration.ofDays(7)); 
        Task<?> winner = ctx.anyOf(event, timer).await(); 
        if (winner == event) {
            response = event.await();
            if (!ctx.getIsReplaying()) {
                context.getLogger().info("winner is the external event");
                ctx.continueAsNew(response);
                return;
            }
        }
        else {
            context.getLogger().info("winner is the timer");
        }

External event logic:

durableContext.getClient().raiseEvent(instanceId, "Approval", object);

Can you please let me know if these are not the right steps to reproduce the issue? Thank you.

from durabletask-java.

kaibocai avatar kaibocai commented on June 3, 2024

In this case, I don't think there is a workaround on SDK side, seems we need to update the DF extension accordingly.
@cgillum , @davidmrdavid do you have some better ideas? Thanks.

from durabletask-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.