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

MPSC race condition in Queue #3187

Closed
djspiewak opened this issue Oct 3, 2022 · 3 comments
Closed

MPSC race condition in Queue #3187

djspiewak opened this issue Oct 3, 2022 · 3 comments
Assignees
Labels

Comments

@djspiewak
Copy link
Member

    "offer/take with a single consumer and high contention" in real {
      constructor(8) flatMap { q =>
        val offerer = List.fill(8)(List.fill(8)(0)).parTraverse_(_.traverse(q.offer(_)))
        offerer.start *> 0.until(8 * 8).toList
          .traverse_(_ => q.take)
          .timeoutTo(8.seconds, IO(false must beTrue))
          .replicateA_(1000)
          .as(ok)
      }
    }

The weirdest bit is this hangs both with the Concurrent version and the new Async one.

@durban
Copy link
Contributor

durban commented Oct 5, 2022

I think the deadlock in this test is due to offerer not being replicateA_'d. At least this version seems to work:

    constructor(8) flatMap { q =>
      val offerer = List.fill(8)(List.fill(8)(0)).parTraverse_(_.traverse(q.offer(_)))
      val taker = 0.until(8 * 8).toList.traverse_(_ => q.take).timeoutTo(8.seconds, IO.raiseError(new TimeoutException("timeout!!!")))
      (offerer.start *> taker).replicateA_(1000).void
    }

@djspiewak
Copy link
Member Author

Oooooooh associativity

@djspiewak
Copy link
Member Author

Confirming that the test is just incorrect. Nuts.

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

2 participants