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

Attempting to call unbound fn: #'hugsql.expr-run/expr--51710943 #59

Closed
dealy663-zz opened this issue Feb 13, 2017 · 5 comments
Closed

Comments

@dealy663-zz
Copy link

Hi

I've been struggling with trying to prevent this type of exception for several days now. There must be some aspect of the binding of sql functions that I'm misunderstanding.

Early on in the startup of my application (on the main thread) my sql files are read by hugsql. Later I startup several threads which need to interact with the DB. There are always several hugsql functions that are successfully called on these threads. But then a little while later (milliseconds) I will get an unbound fn error. Its not always the same function and sometimes my app starts with no problem and no unbound function errors.

When the unbound fn error happens it is only within the first second or two of operation, afterwards it never happens again. The worker threads don't start until after the function which calls the map-of-db-fns on all of my sql files has returned.

I assume it is hugsql that is outputting this error.

Any ideas what might be going wrong here?

@csummers
Copy link
Member

@dealy663 This is strange. Do you have any code that is wiping out namespaces in order to reload them?

Also, this may be tangentially related to issue #46 and the un-threadsafe nature of Clojure's require.

@amoe
Copy link

amoe commented Mar 2, 2017

FWIW I also see this problem occasionally. I use the Rook routing library, which does some magic regarding namespaces, so I've presumed so far that it's some interaction between the two of those. My problem also only happens once, shortly after start up of the JVM, and disappears thereafter.

@tdavis
Copy link

tdavis commented Jul 26, 2017

I see this as well when running a function that uses HugSQL functions via pmap.

ryfow added a commit to ryfow/hugsql that referenced this issue Feb 16, 2018
csummers added a commit that referenced this issue Feb 24, 2018
demonstrate #59 'Attempting to call unbound fn'
@csummers
Copy link
Member

2c61459 should fix this. It at least passes the test from pull request #80.

My solution is to define expressions in an atom, and then Thread/sleep (oof!) until the definition is there. There should be no sleeping for the common case of a single thread loading up a namespace.

@csummers
Copy link
Member

Released in version 0.4.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants