Fork me on GitHub
#babashka
<
2022-05-14
>
Benjamin09:05:03

I ran into this https://bugs.openjdk.java.net/browse/JDK-8218546 issue they fixed it here https://bugs.openjdk.java.net/browse/JDK-8213189 , when will this fix be in graalvm + babashka?

1
Benjamin10:05:53

I can workaround it by using http-1.1 instead of 2

lispyclouds10:05:01

@U02CV2P4J6S which bb version are you using? we are compiling with GraalVM 22.1.0 based on JDK 11.0.15. According to the issue, this is backported to 11.0.14

Benjamin10:05:52

ah I remember now I was using my own compiled one. Should be with graalvm-ce-java11-22.0.0.2 but I will try official bb release

lispyclouds10:05:18

right, since 0.8.0 it should work

Benjamin10:05:26

can confirm it works on 0.8.something

sheluchin17:05:00

I'm getting an intermittent error :cause "Socket closed" when running a simple task like bar (shell "date"). Anyone know why it's happening? I think it started after I began using pods in my bb.edn. I'll post the stacktrace in the thread.

sheluchin17:05:24

$ bb bar
Sat 14 May 2022 01:22:39 PM EDT
#error {
 :cause "Socket closed"
 :via
 [{:type java.net.SocketException
   :message "Socket closed"
   :at [com.oracle.svm.jni.JNIJavaCallWrappers jniInvoke_ARRAY_SocketException_constructor_df417f52c09624a386e25e5af85993f853394076 "JNIJavaCallWrappers.java" 0]}]
 :trace
 [[com.oracle.svm.jni.JNIJavaCallWrappers jniInvoke_ARRAY_SocketException_constructor_df417f52c09624a386e25e5af85993f853394076 "JNIJavaCallWrappers.java" 0]
  [com.oracle.svm.jni.functions.JNIFunctions$NewObjectWithObjectArrayArgFunctionPointer invoke "JNIFunctions.java" -1]
  [com.oracle.svm.jni.functions.JNIFunctions ThrowNew "JNIFunctions.java" 891]
  [java.net.SocketInputStream socketRead0 "SocketInputStream.java" -1]
  [java.net.SocketInputStream socketRead "SocketInputStream.java" 115]
  [java.net.SocketInputStream read "SocketInputStream.java" 168]
  [java.net.SocketInputStream read "SocketInputStream.java" 140]
  [java.net.SocketInputStream read "SocketInputStream.java" 200]
  [java.io.FilterInputStream read "FilterInputStream.java" 83]
  [java.io.PushbackInputStream read "PushbackInputStream.java" 136]
  [bencode.core$read_byte invokeStatic "core.clj" 86]
  [bencode.core$read_token invokeStatic "core.clj" 236]
  [bencode.core$read_bencode invokeStatic "core.clj" 253]
  [babashka.pods.impl$read invokeStatic "impl.clj" 25]
  [babashka.pods.impl$processor$fn__30750 invoke "impl.clj" 169]
  [babashka.pods.impl$processor invokeStatic "impl.clj" 169]
  [babashka.pods.sci$load_pod$fn__30923 invoke "sci.clj" 119]
  [sci.impl.vars$binding_conveyor_fn$fn__343 invoke "vars.cljc" 154]
  [clojure.core$binding_conveyor_fn$fn__5823 invoke "core.clj" 2047]
  [clojure.lang.AFn call "AFn.java" 18]
  [java.util.concurrent.FutureTask run "FutureTask.java" 264]
  [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 628]
  [java.lang.Thread run "Thread.java" 829]
  [com.oracle.svm.core.thread.PlatformThreads threadStartRoutine "PlatformThreads.java" 704]
  [com.oracle.svm.core.posix.thread.PosixPlatformThreads pthreadStartRoutine "PosixPlatformThreads.java" 202]]}

borkdude17:05:35

Can you share your bb.edn? Perhaps the loading of the pod is failing

sheluchin17:05:48

The whole bb.edn is a bit long. Are there any parts of particular interest?

sheluchin18:05:34

{:paths ["src/tasks"]
 :pods {epiccastle/spire {:version "0.1.0-alpha.18"}}
 :tasks
 {:requires ([tasks]
             [server]
             [taoensso.timbre :as log]
             [ :as io]
             [babashka.process :as p :refer [process]])

...
  bar (shell "date")

  server:run-server server/run-server
  server:bootstrap server/bootstrap
  server:git-pull server/git-pull
  server:deploy server/deploy
...

borkdude18:05:13

ok, so this is likely an issue with the spire pod, let me try locally

borkdude18:05:57

With this:

{:pods {epiccastle/spire {:version "0.1.0-alpha.18"}}
 :tasks {bar (shell "date")}}
I get:
$ bb bar
Sat May 14 20:23:38 CEST 2022

borkdude18:05:46

I need a fuller repro, sinces you're loading tasks and server as well in your namespace and I'm not sure what happens there

borkdude18:05:09

you could try to remove those from :requires and then execute bar and see if that works

borkdude18:05:19

so then we know it's something related to those namespaces

sheluchin18:05:18

Yes, it's definitely something in server. If I comment out the require for it, bar always works. Even with just this file:

(ns server
  (:require
   [pod.epiccastle.spire.transport :as transport :refer [ssh]]))
I get the error.

sheluchin18:05:04

I will create a Spire issue for it. Thanks very much.

sheluchin18:05:12

Is there some way to conditionally require pods, BTW? I don't need Spire for the majority of my tasks.

borkdude18:05:16

This does work for me:

{:pods {epiccastle/spire {:version "0.1.0-alpha.18"}}
 :tasks {bar {:requires ([pod.epiccastle.spire.transport :refer [ssh]])
              :task (clojure.repl/doc ssh)}}}
Does it also for you?

borkdude18:05:31

Just that bb.edn and then bb bar

sheluchin18:05:38

That seems to consistently return:

$ bb bar
-------------------------
pod.epiccastle.spire.transport/ssh
([host-string & body])
Macro

borkdude18:05:17

It might be something with bb, I'm not sure. I just need a full repro to say with certainty.

borkdude18:05:31

A git repo I could clone

borkdude18:05:59

You can conditionally load a namespace using require or requiring-resolve

borkdude18:05:14

you can also conditionally load the pod using babashka.pods/`load-pod`

borkdude18:05:37

Note that you need to load the pod first before you can do a require, if you do not declare the pod in bb.edn

sheluchin18:05:30

Thanks, will look into that. https://github.com/sheluchin/bb-spire-pod-repro Would you like a BB issue to go with this?

borkdude18:05:53

let's first diagnose further

sheluchin18:05:37

$ bb --version babashka v0.8.2

borkdude18:05:15

I consistently get:

$ bb bar
Sat May 14 20:58:02 CEST 2022

sheluchin18:05:01

And in my case the error is consistent:

$ bb bar
Sat 14 May 2022 02:58:29 PM EDT
#error {
 :cause "Socket closed"
 :via
 [{:type java.net.SocketException
   :message "Socket closed"
   :at [com.oracle.svm.jni.JNIJavaCallWrappers jniInvoke_ARRAY_SocketException_constructor_df417f52c09624a386e25e5af85993f853394076 "JNIJavaCallWrappers.java" 0]}]
 :trace
 [[com.oracle.svm.jni.JNIJavaCallWrappers jniInvoke_ARRAY_SocketException_constructor_df417f52c09624a386e25e5af85993f853394076 "JNIJavaCallWrappers.java" 0]
  [com.oracle.svm.jni.functions.JNIFunctions$NewObjectWithObjectArrayArgFunctionPointer invoke "JNIFunctions.java" -1]
  [com.oracle.svm.jni.functions.JNIFunctions ThrowNew "JNIFunctions.java" 891]
  [java.net.SocketInputStream socketRead0 "SocketInputStream.java" -1]
  [java.net.SocketInputStream socketRead "SocketInputStream.java" 115]
  [java.net.SocketInputStream read "SocketInputStream.java" 168]
  [java.net.SocketInputStream read "SocketInputStream.java" 140]
  [java.net.SocketInputStream read "SocketInputStream.java" 200]
  [java.io.FilterInputStream read "FilterInputStream.java" 83]
  [java.io.PushbackInputStream read "PushbackInputStream.java" 136]
  [bencode.core$read_byte invokeStatic "core.clj" 86]
  [bencode.core$read_token invokeStatic "core.clj" 236]
  [bencode.core$read_bencode invokeStatic "core.clj" 253]
  [babashka.pods.impl$read invokeStatic "impl.clj" 25]
  [babashka.pods.impl$processor$fn__30750 invoke "impl.clj" 169]
  [babashka.pods.impl$processor invokeStatic "impl.clj" 169]
  [babashka.pods.sci$load_pod$fn__30923 invoke "sci.clj" 119]
  [sci.impl.vars$binding_conveyor_fn$fn__343 invoke "vars.cljc" 154]
  [clojure.core$binding_conveyor_fn$fn__5823 invoke "core.clj" 2047]
  [clojure.lang.AFn call "AFn.java" 18]
  [java.util.concurrent.FutureTask run "FutureTask.java" 264]
  [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 628]
  [java.lang.Thread run "Thread.java" 829]
  [com.oracle.svm.core.thread.PlatformThreads threadStartRoutine "PlatformThreads.java" 704]
  [com.oracle.svm.core.posix.thread.PosixPlatformThreads pthreadStartRoutine "PosixPlatformThreads.java" 202]]}

borkdude19:05:18

The pod may have died after it has just been started, but unfortunately we don't see output about that

borkdude19:05:22

What os are you on?

borkdude19:05:53

ah wait, now I saw it

borkdude19:05:09

it sometimes happens, so I can reproduce it

sheluchin19:05:15

I'm on Ubuntu 21.10.

borkdude19:05:02

the exit code is 0 though, so I suspect it's a benign issue, although it's not very friendly to see this output

sheluchin19:05:06

For me it seems to have gone from intermittent to consistent. I can't get it to not happen now.

borkdude19:05:25

But have you actually tried using the pod?

sheluchin19:05:40

Yep, I use it.

borkdude19:05:53

And does something work not with that? Or is it only this irritating error?

borkdude19:05:57

I agree that we should fix it

sheluchin19:05:35

I think it's benign.

borkdude19:05:09

I'll post an issue at the pods repo

borkdude19:05:11

We should look into it.

sheluchin19:05:07

Ok, I'd be happy to provide any additional info if it would help. Please let me know if there's anything I can add. Otherwise I'll just ignore the error for the time being.

borkdude08:05:30

@UPWHQK562 I pushed a fix to master now (hopefully). Can you test it once the build finishes (should be in 15 minutes from now)? You can install it with

bash <(curl ) --version 0.8.3-SNAPSHOT --dir .

borkdude08:05:57

Should be there now

sheluchin10:05:40

$ while :; do ./bb bar; sleep 1; done
Mon 30 May 2022 06:21:24 AM EDT
Mon 30 May 2022 06:21:25 AM EDT
Mon 30 May 2022 06:21:27 AM EDT
Mon 30 May 2022 06:21:28 AM EDT
Mon 30 May 2022 06:21:29 AM EDT
Mon 30 May 2022 06:21:30 AM EDT
Mon 30 May 2022 06:21:32 AM EDT
Mon 30 May 2022 06:21:33 AM EDT
Mon 30 May 2022 06:21:34 AM EDT
Mon 30 May 2022 06:21:35 AM EDT
Mon 30 May 2022 06:21:37 AM EDT
Mon 30 May 2022 06:21:38 AM EDT
Mon 30 May 2022 06:21:39 AM EDT
Mon 30 May 2022 06:21:41 AM EDT
Looks good, @U04V15CAJ. By comparison using my current version throws up the "socket closed" warning almost every time. Thanks very much!

sheluchin10:05:18

Simply catching the exception and concluding execution without rethrowing? I guess there's no value to it at all?

borkdude10:05:06

The exception is expected when the pod is killed

borkdude10:05:17

So catching it and not doing anything is the correct approach

👍 1
borkdude10:05:15

Normally we expected an EOFException, but with sockets it throws a different one which we hadn't covered

sheluchin10:05:18

I see. Thanks for the explanation. As an aside, I always get a little unsettled when I see the Babashka install script isn't written in bb clojure 😄

borkdude10:05:06

Bootstrap problem ;)