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

Allowing market orders causes occasional bugs! #102

Closed
davidrpugh opened this issue Dec 15, 2015 · 3 comments
Closed

Allowing market orders causes occasional bugs! #102

davidrpugh opened this issue Dec 15, 2015 · 3 comments
Labels

Comments

@davidrpugh
Copy link
Contributor

Here is an example of the stack trace...

[ERROR] [12/15/2015 14:16:21.061] [model-market-dispatcher-6] [akka://model/user/$b/clearing-mechanism] next on empty iterator
java.util.NoSuchElementException: next on empty iterator
    at scala.collection.immutable.RedBlackTree$TreeIterator.next(RedBlackTree.scala:475)
    at scala.collection.IterableLike$class.head(IterableLike.scala:107)
    at scala.collection.mutable.TreeSet.head(TreeSet.scala:41)
    at scala.collection.TraversableLike$class.headOption(TraversableLike.scala:440)
    at scala.collection.mutable.TreeSet.headOption(TreeSet.scala:41)
    at markets.clearing.engines.CDAMatchingEngine.accumulateBidOrders(CDAMatchingEngine.scala:108)
    at markets.clearing.engines.CDAMatchingEngine.findMatch(CDAMatchingEngine.scala:66)
    at markets.clearing.ClearingMechanismLike$$anonfun$clearingMechanismBehavior$1.applyOrElse(ClearingMechanismLike.scala:39)
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:170)
    at akka.actor.Actor$class.aroundReceive(Actor.scala:480)
    at markets.clearing.ClearingMechanismActor.aroundReceive(ClearingMechanismActor.scala:39)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
    at akka.actor.ActorCell.invoke(ActorCell.scala:495)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
    at akka.dispatch.Mailbox.run(Mailbox.scala:224)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Here is the application.conf file used to generate the bug. Bug appeared as soon as I started allowing market orders. This suggests that bug occurs when either askOrderBook or bidOrderBook is empty?

Possibly a bug with TreeSet? Seems unlikely...

@davidrpugh davidrpugh added the bug label Dec 15, 2015
@davidrpugh
Copy link
Contributor Author

I can no longer replicate this issue so I am going to close for now...

@davidrpugh
Copy link
Contributor Author

I have found the source of this issue: my stupidity. I was creating a single (mutable!) MatchingEngine object and passing it around to a bunch of market actors creating that were mutating it concurrently! Bad...

@davidrpugh
Copy link
Contributor Author

I forgot to close this issue! Solved it a while back...

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