-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add RPC for loading a model #1114
Comments
A light refactor of the `execute` method in the `SanyParserPassImpl`. I prepared this initially to support #1114, but realized it wasn't quite the right way to meet the needs of the server. Still, I think it's a nice enough cleanup to be worth integrating. The refactor just breaks the execution logic into three chunks with some helper functions and uses a for comprehension over `Either` to sequence the possible error cases.
As discussed in MondApalache, looks like this is blocked by #1761 |
I think I should be able to work around for the moment, either by making the tests run in sequence, or manipulating the temp dir system attribute. |
So, after adding a workaround for the race condition of the temp dir, I think I've found the actual problem, which is a deeper issue. Not yet sure if there will be workarounds or if we'll need to submit a fix upstream. The failure I am seeing from Shai when trying parse two specs concurrently is seems to be related to a detail of the
And the documentation on this in the JavaCC docs:
|
Looks like the SANY object provides a method to take care of this, so the fix should be simple here :) |
Oh, and in fact that method is getting called at the start of every invocation of the method we are invoking, so I'm back to confusion about the problem here and how to fix it, lol. So we call and that calls a function meant to set up the global environment on each call: So maybe the problem I'm hitting, as @thpani pointed out, that one parse invocation is being called before another has finished.... but I think I'm sequencing the calls. Will continue investigating. |
Ok, so of course we can run the parses in sequence, because we run them in the same VM in our tests (:facepalm:), and confirmed that if I ensure strict sequencing of the parses everything works out as expected: testM("cal load two valid specs in sequence") {
val specA =
"""|---- MODULE A ----
|Foo == TRUE
|====
|""".stripMargin
val specB =
"""|---- MODULE B ----
|Foo == TRUE
|====
|""".stripMargin
for {
s <- service
conn <- s.openConnection(ConnectRequest())
respA <- s.loadModel(LoadModelRequest(conn.id, specA))
respB <- s.loadModel(LoadModelRequest(conn.id, specB))
} yield assert(respA.result.isSpec && respB.result.isSpec)(isTrue)
}, So I just need to ensure that we're only allowing one instance of the parser to run at a time. |
This looks like a limitation of the SANY parser, which was generated by JavaCC. I am not sure how hard it would be for the tlaplus team to make sure that SANY works in a multithreaded environment. Since parsing works relatively fast in comparison to other passes, I can only think of a very simple solution: introduce a mutex that gets locked on every call to SANY. We would lose the ability to call the parser in parallel, but avoid other unexpected issues. |
Shon's already using a semaphore in #1855. I also agree that this is the best workaround. |
Work on this will involve adding the RPC calls for these the following methods, specified in RFC10
It will include:
The text was updated successfully, but these errors were encountered: