Skip to content

Commit

Permalink
RD-10002 Query interruption in Truffle. (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelbranco80 authored Nov 17, 2023
1 parent 11cabe5 commit cdb0d12
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
8 changes: 4 additions & 4 deletions launcher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<raw-launcher.version>1.0-SNAPSHOT</raw-launcher.version>
<raw-client.version>0.26.3+4-f7ff164e+20231115-1742-SNAPSHOT</raw-client.version>
<raw-snapi-client.version>0.26.3+4-f7ff164e+20231115-1744-SNAPSHOT</raw-snapi-client.version>
<raw-python-client.version>0.26.3+4-f7ff164e+20231115-1744-SNAPSHOT</raw-python-client.version>
<raw-client.version>0.27.0+0-11cabe5f+20231117-0739-SNAPSHOT</raw-client.version>
<raw-snapi-client.version>0.27.0+0-11cabe5f+20231117-0741-SNAPSHOT</raw-snapi-client.version>
<raw-python-client.version>0.27.0+0-11cabe5f+20231117-0741-SNAPSHOT</raw-python-client.version>
</properties>

<groupId>com.raw-labs.com</groupId>
<artifactId>raw-launcher</artifactId>
<version>0.26.3+4-f7ff164e+20231115-1744-SNAPSHOT</version>
<version>0.27.0+0-11cabe5f+20231117-0741-SNAPSHOT</version>

<dependencies>
<!-- GraalVM Polyglot Dependency -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,18 @@ class Rql2TruffleCompilerService(maybeClassLoader: Option[ClassLoader] = None)(
EvalSuccess(rawValue)
} catch {
case ex: PolyglotException =>
// (msb): The following are various "hacks" to ensure the inner language InterruptException propagates "out".
// Unfortunately, I do not find a more reliable alternative; the branch that does seem to work is the one
// that does startsWith. That said, I believe with Truffle, the expectation is that one is supposed to
// "cancel the context", but in our case this doesn't quite match the current architecture, where we have
// other non-Truffle languages and also, we have parts of the pipeline that are running outside of Truffle
// and which must handle interruption as well.
if (ex.isInterrupted) {
throw new InterruptedException()
} else if (ex.getCause.isInstanceOf[InterruptedException]) {
throw ex.getCause
} else if (ex.getMessage.startsWith("java.lang.InterruptedException")) {
throw new InterruptedException()
} else if (ex.isGuestException) {
val err = ex.getGuestObject
if (err != null && err.hasMembers && err.hasMember("errors")) {
Expand Down Expand Up @@ -363,8 +373,18 @@ class Rql2TruffleCompilerService(maybeClassLoader: Option[ClassLoader] = None)(
}
} catch {
case ex: PolyglotException =>
// (msb): The following are various "hacks" to ensure the inner language InterruptException propagates "out".
// Unfortunately, I do not find a more reliable alternative; the branch that does seem to work is the one
// that does startsWith. That said, I believe with Truffle, the expectation is that one is supposed to
// "cancel the context", but in our case this doesn't quite match the current architecture, where we have
// other non-Truffle languages and also, we have parts of the pipeline that are running outside of Truffle
// and which must handle interruption as well.
if (ex.isInterrupted) {
throw new InterruptedException()
} else if (ex.getCause.isInstanceOf[InterruptedException]) {
throw ex.getCause
} else if (ex.getMessage.startsWith("java.lang.InterruptedException")) {
throw new InterruptedException()
} else if (ex.isGuestException) {
val err = ex.getGuestObject
if (err != null && err.hasMembers && err.hasMember("errors")) {
Expand Down

0 comments on commit cdb0d12

Please sign in to comment.