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

Fix MatchError in Xandra.Cluster.ControlConnection #303

Merged
merged 3 commits into from
May 2, 2023
Merged

Conversation

whatyouhide
Copy link
Owner

@whatyouhide whatyouhide commented May 1, 2023

Closes #300.

@harunzengin did you see change events come in in protocol v5 and debug log something? Because by looking at the code it looks like this code should have never worked, for any protocol module.

@whatyouhide whatyouhide changed the title WIP Fix MatchError in Xandra.Cluster.ControlConnection May 1, 2023
@whatyouhide whatyouhide marked this pull request as ready for review May 1, 2023 18:06
@whatyouhide whatyouhide merged commit a8605d4 into main May 2, 2023
13 checks passed
@whatyouhide whatyouhide deleted the al/fix branch May 2, 2023 07:36
@harunzengin
Copy link
Contributor

harunzengin commented May 2, 2023

Okay, I tried this now in v5 and got the following:

iex(13)> [error] xandra_address=172.25.0.10 xandra_port=9042 module=telemetry  Handler "xandra-default-telemetry-handler" has failed and has been detached. Class=:error
Reason={:badmatch,
 %{
   changed: true,
   cluster_name: nil,
   cluster_pid: #PID<0.285.0>,
   event_type: :host_up,
   host: %Xandra.Cluster.Host{
     address: {172, 25, 0, 14},
     port: 9042,
     data_center: "munich",
     host_id: "5c918d97-84d0-4eac-a2f3-4d3b78390afe",
     rack: "m1",
     release_version: "4.1.1",
     schema_version: "54e17321-3f2e-37ca-9b08-d91ba7bdd369",
     tokens: MapSet.new(["-1725087107571814018", "-2821129007806752307",
      "-4599763308630339436", "-5577908761146453511", "-633789996879601758",
      "-7196932056843496809", "-8786936609357395447", "1650854880514143236",
      "210586650611559998", "2722355496854176049", "3740206901596603064",
      "4557878834208953859", "5633634715434533398", "6369550408145427039",
      "7448923215593028697", "8692443221273620669"])
   },
   source: :xandra
 }}
Stacktrace=[
  {Xandra.Telemetry, :handle_event, 4,
   [file: 'lib/xandra/telemetry.ex', line: 215]},
  {:telemetry, :"-execute/3-fun-0-", 4,
   [
     file: '/xandra/deps/telemetry/src/telemetry.erl',
     line: 160
   ]},
  {:lists, :foreach_1, 2, [file: 'lists.erl', line: 1442]},
  {Xandra.Cluster.ControlConnection, :"-refresh_topology/2-fun-1-", 4,
   [file: 'lib/xandra/cluster/control_connection.ex', line: 463]},
  {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 2468]},
  {Xandra.Cluster.ControlConnection, :refresh_topology, 2,
   [file: 'lib/xandra/cluster/control_connection.ex', line: 455]},
  {Xandra.Cluster.ControlConnection, :handle_event, 4,
   [file: 'lib/xandra/cluster/control_connection.ex', line: 216]},
  {:gen_statem, :loop_state_callback, 11, [file: 'gen_statem.erl', line: 1428]}
]

[debug] module=Xandra.Cluster  Host marked as UP: 172.25.0.14:9042

@harunzengin
Copy link
Contributor

I did get the host up message in v5 though:

handler = fn event_name, measurements, metadata, :no_config -> IO.inspect({event_name, measurements, metadata}) end

events = [
    [:xandra, :cluster, :change_event],
    [:xandra, :cluster, :control_connection, :connected],
    [:xandra, :cluster, :control_connection, :disconnected]
]

:telemetry.attach_many(
    "xandra-default-telemetry-handler",
    events,
    handler,
    :no_config
)


{[:xandra, :cluster, :change_event], %{},
 %{
   changed: true,
   cluster_name: nil,
   cluster_pid: #PID<0.330.0>,
   event_type: :host_up,
   host: %Xandra.Cluster.Host{
     address: {172, 25, 0, 14},
     port: 9042,
     data_center: "munich",
     host_id: "5c918d97-84d0-4eac-a2f3-4d3b78390afe",
     rack: "m1",
     release_version: "4.1.1",
     schema_version: "54e17321-3f2e-37ca-9b08-d91ba7bdd369",
     tokens: MapSet.new(["-1725087107571814018", "-2821129007806752307",
      "-4599763308630339436", "-5577908761146453511", "-633789996879601758",
      "-7196932056843496809", "-8786936609357395447", "1650854880514143236",
      "210586650611559998", "2722355496854176049", "3740206901596603064",
      "4557878834208953859", "5633634715434533398", "6369550408145427039",
      "7448923215593028697", "8692443221273620669"])
   },
   source: :xandra
 }}
iex(11)> [debug] module=Xandra.Cluster  Host marked as UP: 172.25.0.14:9042
{[:xandra, :cluster, :change_event], %{},
 %{
   changed: true,
   cluster_name: nil,
   cluster_pid: #PID<0.330.0>,
   event_type: :host_up,
   host: %Xandra.Cluster.Host{
     address: {172, 25, 0, 15},
     port: 9042,
     data_center: "munich",
     host_id: "1e52d167-f5bf-4110-9758-bac311261afd",
     rack: "m1",
     release_version: "4.1.1",
     schema_version: "54e17321-3f2e-37ca-9b08-d91ba7bdd369",
     tokens: MapSet.new(["-1266273665991915476", "-170231765756977187",
      "-3044907966815502605", "-4023053419331616680", "-5642076715028659978",
      "-7232081267542558616", "-8199445510621094115", "1765441992426396829",
      "3205710222328980067", "4277210838669012880", "5295062243411439895",
      "6112734176023790690", "7188490057249370229", "7924405749960263870",
      "9003778557407865528", "921065344935235072"])
   },
   source: :xandra
 }}
{[:xandra, :cluster, :change_event], %{},
 %{
   changed: true,
   cluster_name: nil,
   cluster_pid: #PID<0.330.0>,
   event_type: :host_up,
   host: %Xandra.Cluster.Host{
     address: {172, 25, 0, 13},
     port: 9042,
     data_center: "munich",
     host_id: "c241a140-ebf8-4f3d-8492-e36d6b79fabb",
     rack: "m1",
     release_version: "4.1.1",
     schema_version: "54e17321-3f2e-37ca-9b08-d91ba7bdd369",
     tokens: MapSet.new(["-1619907276706579294", "-2695663157932158834",
      "-3513335090544509628", "-4531186495286936644", "-5602687111626969456",
      "-7042955341529552696", "-7887331989020714453", "-883991583995685654",
      "-8978629099712926713", "1438901229132507975", "195381223451916003",
      "2406265472211043474", "3996270024724942112", "5615293320421985409",
      "6593438772938099485", "8372073073761686613"])
   },
   source: :xandra
 }}
iex(11)> [debug] module=Xandra.Cluster  Host marked as UP: 172.25.0.15:9042
[debug] module=Xandra.Cluster  Host marked as UP: 172.25.0.13:9042

@whatyouhide
Copy link
Owner Author

@harunzengin #304

whatyouhide added a commit that referenced this pull request May 2, 2023
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

Successfully merging this pull request may close these issues.

%StatusChange{} causes MatchError in protocol v4
2 participants