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

FunctionClauseError in anonymous fn/2 in Mariaex.LruCache.take_oldest/1 #153

Closed
marcelotto opened this issue Nov 30, 2016 · 2 comments
Closed

Comments

@marcelotto
Copy link

I'm having problems with the execution of a raw sql query on a legacy MySQL db for migration purposes.

SELECT id FROM pictures
WHERE event_id = #{event_id} AND tags REGEXP '[[:<:]]#{tag}[[:>:]]'

First, I couldn't run the query at all, but was getting a handle_close/3 not implemented error. When I noticed some recent changes on Mariaex relating to handle_close, I did upgrade to Mariaex 0.8.0, which fixed this problem.

Although the query can be executed now, it fails after 495 executions during the migration with the following error:

14:54:44.099 [error] GenServer #PID<0.369.0> terminating
** (DBConnection.ConnectionError) client #PID<0.70.0> stopped: ** 
(FunctionClauseError) no function clause matching in anonymous fn/2 in Mariaex.LruCache.take_oldest/1
    lib/mariaex/lru_cache.ex:57: anonymous fn({:__counter__, 198}, {"SELECT id\nFROM pictures\nWHERE ((event_id = 1) AND tags REGEXP '[[:<:]]o[[:>:]]')\n", 2, 1, #Reference<0.0.2.66>, 0}) in Mariaex.LruCache.take_oldest/1
    (stdlib) lists.erl:1263: :lists.foldl/3
    (stdlib) ets.erl:585: :ets.do_foldl/4
    (stdlib) ets.erl:574: :ets.foldl/3
    lib/mariaex/lru_cache.ex:57: Mariaex.LruCache.take_oldest/1
    lib/mariaex/protocol.ex:317: Mariaex.Protocol.prepare_lookup/2
    lib/mariaex/protocol.ex:298: Mariaex.Protocol.handle_prepare/3
    (db_connection) lib/db_connection.ex:957: DBConnection.handle/4

    (db_connection) lib/db_connection/connection.ex:243: DBConnection.Connection.handle_cast/2
    (connection) lib/connection.ex:488: Connection.handle_call/3
    (stdlib) gen_server.erl:615: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:647: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

The failure doesn't seem to be related to the specific 495th execution of this query, since the same error is raised on another query on the first run of the migration which does some clean up that's omitted after clean up on subsequent migration runs.

@marcelotto
Copy link
Author

Your fix solved the problem. Thank you very much.

@liveforeverx
Copy link
Member

@marcelotto Thank you for reporting!

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

2 participants