mysqlgocgoshared-objectsmysql-udf

MySQL UDF returns "Error Code: 1127. Can't find symbol 'xx' in library"


I have a MySQL UDF written in Go that used to work just fine, but if I compile now it no longer functions, with the error message

Error Code: 1127. Can't find symbol 'get_url_param' in library

The UDF is on GitHub here: https://github.com/StirlingMarketingGroup/mysql-get-url-param

If I check the exports from the old compiled file like this

$ nm get_url_param.old.so | grep get_url_param
00000000000f21f0 T _cgoexp_38fa52dfc07b_get_url_param
00000000000f20c0 T _cgoexp_38fa52dfc07b_get_url_param_deinit
00000000000f2130 T _cgoexp_38fa52dfc07b_get_url_param_init
00000000000f2af0 T get_url_param
00000000000f2a00 T get_url_param_deinit
00000000000f2a70 T get_url_param_init
00000000000f2250 t main._cgoexpwrap_38fa52dfc07b_get_url_param
00000000000f2690 t main._cgoexpwrap_38fa52dfc07b_get_url_param.func1
00000000000f2120 t main._cgoexpwrap_38fa52dfc07b_get_url_param_deinit
00000000000f2190 t main._cgoexpwrap_38fa52dfc07b_get_url_param_init
00000000000f24f0 t main.get_url_param
00000000000f2460 t main.get_url_param_init

and this file works just fine when running

create function`get_url_param`returns string soname'get_url_param.so';

but then when I compile the same exact code with the same command

go build -buildmode=c-shared -o get_url_param.so

And then check the exports the same way

$ nm get_url_param.so | grep get_url_param
0000000000109360 T _cgoexp_d994eb9c9c89_get_url_param
0000000000109230 T _cgoexp_d994eb9c9c89_get_url_param_deinit
00000000001092a0 T _cgoexp_d994eb9c9c89_get_url_param_init
0000000000109a50 T get_url_param
0000000000109960 T get_url_param_deinit
00000000001099d0 T get_url_param_init
00000000001093c0 t main._cgoexpwrap_d994eb9c9c89_get_url_param
0000000000109820 t main._cgoexpwrap_d994eb9c9c89_get_url_param.func1
0000000000357cb0 d main._cgoexpwrap_d994eb9c9c89_get_url_param.stkobj
0000000000109290 t main._cgoexpwrap_d994eb9c9c89_get_url_param_deinit
0000000000109300 t main._cgoexpwrap_d994eb9c9c89_get_url_param_init
0000000000109680 t main.get_url_param
0000000000357cd0 d main.get_url_param.stkobj
00000000001095f0 t main.get_url_param_init

It all looks right. And I can tell I'm checking the right file since all the addresses are different (plus there's a new line for whatever main.get_url_param.stkobj is). But trying to add it this time gives me the error about how MySQL can't find the symbol in the library.

I'm super sure the compiling commands stayed the same, and I don't think it has anything to do with Go versions, as I tested back to Go 1.9 and it does the same thing, still not working.

I've uploaded both binaries as well as releases with the old one that works, and the new one that doesn't work. Both .so files are being copied the same way to my plugin dir, so I don't think it's something about permissions. Also, it's definitely not anything to do with the Go func name being lowercase, as the behavior is exactly the same even if I rename my function to GetURLParam, and I can see the exports with nm.

I'm sure I'm missing something, probably with the compiling command, or maybe some cgo flags, but I just have no idea what that'd be.


Solution

  • In past I had the same issue and (only) restart of the server helped. If I remembed correctly, something was cached and even a fully recompiled/replaced library file was not reloaded correctly.

    So:

    1. recompile the plugin
    2. test on different machine using the same OS / MySQL version
    3. copy to the production machine
    4. restart the production machine
    5. evaluate