Git Product home page Git Product logo

Comments (4)

elasticsearchmachine avatar elasticsearchmachine commented on July 20, 2024

Pinging @elastic/es-data-management (Team:Data Management)

from elasticsearch.

masseyke avatar masseyke commented on July 20, 2024

It looks like assertBusy didn't fix #44997.

from elasticsearch.

masseyke avatar masseyke commented on July 20, 2024

I can reproduce this 100% of the time in the debugger by just putting a breakpoint on the final int currentCount2 = triggerCount.get(); line. Immediately after that line, triggerCount is incremented in this block:

            trigger.set(e -> {
                triggeredJobs.add(e.getJobName());
                triggerCount.incrementAndGet();
            });

from elasticsearch.

masseyke avatar masseyke commented on July 20, 2024

I think we have a race condition, and I think the failing assertion is just invalid because we don't want to fix this race condition. Here's the relevant code, with comments added:

            final int currentCount2 = triggerCount.get();   // At this point we get the number of jobs. Say it's 2.
            previousState = state;
            // Create a state simulating the policy being deleted
            state = createState(
                new SnapshotLifecycleMetadata(Collections.emptyMap(), OperationMode.RUNNING, new SnapshotLifecycleStats()),
                true
            );
            event = new ClusterChangedEvent("5", state, previousState);
            sls.clusterChanged(event);    // At this point, we cancel any future jobs. But it is entirely possible that a job has run between the first line above and this one. So now triggerCount could be 3 (or even more)
            clock.fastForwardSeconds(2);

            // The existing job should be cancelled and no longer trigger
            assertBusy(() -> assertThat(triggerCount.get(), equalTo(currentCount2))); // If the race condition happened, this will never be true

I don't think we want any additional locking, or to change SchedulerEngine$ActiveSchedule.cancel() to set a flag that listeners need to check, because it's not worth the complexity or risk. I think we just need to accept that sometimes triggerCount might be greater than currentCount2.

from elasticsearch.

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.