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

Crash on update #106

Closed
awalias opened this issue Jan 22, 2021 · 3 comments · Fixed by #111
Closed

Crash on update #106

awalias opened this issue Jan 22, 2021 · 3 comments · Fixed by #111
Labels
bug Something isn't working released

Comments

@awalias
Copy link
Member

awalias commented Jan 22, 2021

I added the demo schema countries which can be found on the dashboard under sql editor

I subscribed using:

  const countries = supabase
    .from("countries")
    .on("*", (payload) => {
      console.log("Change received!", payload);
    })
    .subscribe();

And I edited some text fields on the countries table in the table editor

no updates came through on my subscription and when I checked the realtime logs I found the error below.

I can't reproduce it, but perhaps it's possible to trace it from the logs?

** (UndefinedFunctionError) function :undefined.handle_message/4 is undefined (module :undefined is not available)
    :undefined.handle_message(90, "I", {:state, :gen_tcp, #Port<0.36>, "", {9311, 658334535}, :on_message, {:codec, [], {:oid_db, %{3908 => {:type, 3908, :tsrange, false, :undefined, :epgsql_codec_timerange, :epgsql_idatetime}, 3905 => {:type, 3905, :int4range, true, 3904, :epgsql_codec_intrange, []}, 3912 => {:type, 3912, :daterange, false, :undefined, :epgsql_codec_timerange, :epgsql_idatetime}, 775 => {:type, 775, :macaddr8, true, 774, :epgsql_codec_net, []}, 2950 => {:type, 2950, :uuid, false, :undefined, :epgsql_codec_uuid, []}, 600 => {:type, 600, :point, false, :undefined, :epgsql_codec_geometric, []}, 1001 => {:type, 1001, :bytea, true, 17, :epgsql_codec_text, []}, 1266 => {:type, 1266, :timetz, false, :undefined, :epgsql_codec_datetime, :epgsql_idatetime}, 199 => {:type, 199, :json, true, 114, :epgsql_codec_json, []}, 1017 => {:type, 1017, :point, true, 600, :epgsql_codec_geometric, []}, 3913 => {:type, 3913, :daterange, true, 3912, :epgsql_codec_timerange, :epgsql_idatetime}, 20 => {:type, 20, :int8, false, :undefined, :epgsql_codec_integer, []}, 1007 => {:type, 1007, :int4, true, 23, :epgsql_codec_integer, []}, 17 => {:type, 17, :bytea, false, :undefined, :epgsql_codec_text, []}, 25 => {:type, 25, :text, false, :undefined, :epgsql_codec_text, []}, 3909 => {:type, 3909, :tsrange, true, 3908, :epgsql_codec_timerange, :epgsql_idatetime}, 1022 => {:type, 1022, :float8, true, 701, :epgsql_codec_float, []}, 1270 => {:type, 1270, :timetz, true, 1266, :epgsql_codec_datetime, :epgsql_idatetime}, 1182 => {:type, 1182, :date, true, 1082, :epgsql_codec_datetime, :epgsql_idatetime}, 829 => {:type, 829, :macaddr, false, :undefined, :epgsql_codec_net, []}, 1082 => {:type, 1082, :date, false, :undefined, :epgsql_codec_datetime, :epgsql_idatetime}, 1042 => {:type, 1042, :bpchar, false, :undefined, :epgsql_codec_bpchar, []}, 3927 => {:type, 3927, :int8range, true, 3926, :epgsql_codec_intrange, []}, 3910 => {:type, 3910, :tstzrange, false, :undefined, :epgsql_codec_timerange, :epgsql_idatetime}, 1186 => {:type, 1186, :interval, false, :undefined, :epgsql_codec_datetime, :epgsql_idatetime}, 1115 => {:type, 1115, :timestamp, true, 1114, :epgsql_codec_datetime, :epgsql_idatetime}, 2951 => {:type, 2951, :uuid, true, 2950, :epgsql_codec_uuid, []}, 1014 => {:type, 1014, :bpchar, true, 1042, :epgsql_codec_bpchar, []}, 1183 => {:type, 1183, :time, true, 1083, :epgsql_codec_datetime, :epgsql_idatetime}, 651 => {:type, 651, :cidr, true, 650, :epgsql_codec_net, []}, 3926 => {:type, 3926, :int8range, false, :undefined, :epgsql_codec_intrange, []}, 1000 => {:type, 1000, :bool, true, 16, :epgsql_codec_boolean, ...}, 1187 => {:type, 1187, :interval, true, 1186, ...}, 1043 => {:type, 1043, :varchar, false, ...}, 774 => {:type, 774, :macaddr8, ...}, 3904 => {:type, 3904, ...}, 1040 => {:type, ...}, 3802 => {...}, ...}, %{{:int8range, true} => 3927, {:timestamp, false} => 1114, {:int4, true} => 1007, {:int2, true} => 1005, {:float8, true} => 1022, {:macaddr, true} => 1040, {:daterange, false} => 3912, {:timestamptz, false} => 1184, {:json, true} => 199, {:inet, false} => 869, {:point, false} => 600, {:macaddr, false} => 829, {:bpchar, true} => 1014, {:float4, false} => 700, {:time, false} => 1083, {:int2, false} => 21, {:bool, false} => 16, {:float8, false} => 701, {:bytea, true} => 1001, {:bool, true} => 1000, {:macaddr8, false} => 774, {:int8, true} => 1016, {:uuid, true} => 2951, {:int8range, false} => 3926, {:tsrange, true} => 3909, {:timetz, true} => 1270, {:tstzrange, true} => 3911, {:point, true} => 1017, {:text, false} => 25, {:text, true} => 1009, {:float4, true} => 1021, {:char, true} => 1002, {:daterange, true} => 3913, {:interval, true} => 1187, {:date, false} => 1082, {:int4range, ...} => 3905, {...} => 3807, ...}}}, {[], []}, :undefined, :undefined, :undefined, :undefined, [{"application_name", ""}, {"client_encoding", "UTF8"}, {"DateStyle", "ISO, MDY"}, {"integer_datetimes", "on"}, {"IntervalStyle", "postgres"}, {"is_superuser", "on"}, {"server_encoding", "UTF8"}, {"server_version", "12.5 (Ubuntu 12.5-1.pgdg18.04+1)"}, {"session_authorization", "supabase_admin"}, {"standard_conforming_strings", "on"}, {"TimeZone", "UTC"}], [], [], true, 73, :undefined, {:repl, :undefined, 0, 0, :undefined, :undefined, :undefined, #PID<0.2871.0>, false}}, :undefined)
    (epgsql 4.3.0) /home/runner/work/realtime/realtime/server/deps/epgsql/src/epgsql_sock.erl:294: :epgsql_sock.command_handle_message/3
    (epgsql 4.3.0) /home/runner/work/realtime/realtime/server/deps/epgsql/src/epgsql_sock.erl:378: :epgsql_sock.loop/1
    (stdlib 3.12.1) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib 3.12.1) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:tcp, #Port<0.36>, <<90, 0, 0, 0, 5, 73>>}
@awalias awalias added the bug Something isn't working label Jan 22, 2021
@w3b6x9
Copy link
Member

w3b6x9 commented Jan 24, 2021

@awalias just wanted to confirm that you were able to subscribe successfully in the first place and receive insert payload notifications? Were there any GenServer #PID<0.1234.0> terminating (stop) :econnrefused in the logs prior to the presence of UndefinedFunctionError?

@awalias
Copy link
Member Author

awalias commented Jan 29, 2021

from @w3b6x9 :

I am able to reproduce this consistently now. Here's what I think is going on:
• We are using the same db connection (epgsql_pid) for both SELECT and CREATE_REPLICATION_SLOT queries. epgsql streaming replication docs told us not to do that:
Only simple queries squery can be used in replication mode and only special commands accepted in this mode (e.g DROP_REPLICATION_SLOT, CREATE_REPLICATION_SLOT, IDENTIFY_SYSTEM).
Note: you have to create new connection with the not-replication mode to select initial state of tables, since you cannot run SELECT in replication mode connection.
• When the epgsql server continuously restarts, you consistently receive :undefined.handle_message(90, "I"...) . I believe this has to do with epgsql, specifically epgsql_sock, using an internal queue:
%%% epgsql_sock'...as soon as %%% it receives a new command, it sends it to the server immediately and then %%% it puts command's callbacks and state into internal queue of all the commands %%% which were sent to the server and waiting for response. So it knows in which %%% order it should call each pipelined command's handle_message' callback.
Also, 90 refers to epgsql message topic READY_FOR_QUERY , which points to the SELECT queries we're making. I think the SELECT :undefined.handle_message(90, "I"...) is blocking replication.
Here's some quick code I wrote to reproduce this error:
615590b

@github-actions
Copy link

🎉 This issue has been resolved in version 0.10.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants