Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MB-100: tolerate unknown nodes in master_events formatting

I've found /diag not to work sometimes due to bug in master_events
formatting which assumes all nodes it may ever see in master events
will be known. But that's not true particularly for events from before
node renaming, which refer nodes under old names.

Change-Id: Ia75aa703f428c00dfc22826b23fc3312fedfc7b5
Reviewed-on: http://review.couchbase.org/25399
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information...
commit 932b5489a587d4bc0988e74cab073ba32828277e 1 parent 1afb8b6
@alk alk authored alk committed
Showing with 9 additions and 10 deletions.
  1. +8 −9 src/master_activity_events.erl
  2. +1 −1  src/ns_memcached.erl
View
17 src/master_activity_events.erl
@@ -312,11 +312,11 @@ format_mcd_pair({Host, Port}) ->
node_to_host(undefined, _Config) ->
<<"">>;
node_to_host(Node, Config) ->
- case lists:member(Node, [node() | nodes()]) of
- true ->
- format_mcd_pair(ns_memcached:host_port(Node, Config));
- false ->
- atom_to_binary(Node, latin1)
+ case ns_memcached:host_port(Node, Config) of
+ {_, undefined} ->
+ atom_to_binary(Node, latin1);
+ HostPort ->
+ format_mcd_pair(HostPort)
end.
maybe_get_pids_node(Pid) when is_pid(Pid) ->
@@ -373,11 +373,10 @@ event_to_jsons({TS, deregister_tap_name, Pid, Bucket, Src, Name}) ->
{host, format_mcd_pair(Src)},
{name, Name}])];
event_to_jsons({TS, vbucket_state_change, Bucket, Node, VBucketId, NewState}) ->
- Host = ns_memcached:host_port(Node),
[format_simple_plist_as_json([{type, vbucketStateChange},
{ts, misc:time_to_epoch_float(TS)},
{bucket, Bucket},
- {host, format_mcd_pair(Host)},
+ {host, node_to_host(Node, ns_config:get())},
{vbucket, VBucketId},
{state, NewState}])];
@@ -479,7 +478,7 @@ event_to_jsons({TS, bucket_failover_started, BucketName, Node, Pid}) ->
[format_simple_plist_as_json([{type, bucketFailoverStarted},
{ts, misc:time_to_epoch_float(TS)},
{bucket, BucketName},
- {host, format_mcd_pair(ns_memcached:host_port(Node))},
+ {host, node_to_host(Node, ns_config:get())},
{pid, Pid},
{node, maybe_get_pids_node(Pid)}])];
@@ -487,7 +486,7 @@ event_to_jsons({TS, bucket_failover_ended, BucketName, Node, Pid}) ->
[format_simple_plist_as_json([{type, bucketFailoverEnded},
{ts, misc:time_to_epoch_float(TS)},
{bucket, BucketName},
- {host, format_mcd_pair(ns_memcached:host_port(Node))},
+ {host, node_to_host(Node, ns_config:get())},
{pid, Pid},
{node, maybe_get_pids_node(Pid)}])];
View
2  src/ns_memcached.erl
@@ -957,7 +957,7 @@ get_vbucket(Node, Bucket, VBucket) ->
-spec host_port(node(), any()) ->
- {nonempty_string(), pos_integer()}.
+ {nonempty_string(), pos_integer() | undefined}.
host_port(Node, Config) ->
DefaultPort = ns_config:search_node_prop(Node, Config, memcached, port),
Port = ns_config:search_node_prop(Node, Config,
Please sign in to comment.
Something went wrong with that request. Please try again.