Skip to content

Deadlock in lifecycle #364

@TimGuan

Description

@TimGuan

When I've been trying to use singleton of PersistStatemache(according to the perssit demo( demo.persist.Persist)) with multiple test steps I've faced with deadlock problem. I just use the syncTaskExecutor by default and let the thread sleep to simulate the slow processing. This is with 1.2.5.RELEASE.

    public void configure(StateMachineConfigurationConfigurer<String, String> config)
        throws Exception {
        config
            .withConfiguration()
            .autoStartup(true);
    }
    public void pay() {
        logger.info("WAITING_FOR_RECEIVE    " +Thread.currentThread());
        try {
            Thread.sleep(3000);
            logger.info("wakeup" + "  " + Thread.currentThread());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

My test case:

    @Test
    public void doSignals() throws InterruptedException {
        int cnt = 5;
        Thread[] threads = new Thread[cnt];
        for (int i = 0; i < cnt; i++) {
            threads[i] = new Thread(() -> {
                try {
                    persist.change(1L, "PAY");// accpet the same event  
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
        }
        for (Thread t : threads) {
            t.start();
        }
        for (Thread t : threads) {
            t.join();
        }
    }

jstack result:
capture image
capture image1
By the way my spring statemachine version is 1.2.5.RELEASE

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions