You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Zhang Yifan (Code Review)" <ge...@cloudera.org> on 2019/01/07 03:20:56 UTC

[kudu-CR] KUDU-2348: In the Java client, pick a random replica when no replica is local

Zhang Yifan has uploaded this change for review. ( http://gerrit.cloudera.org:8080/12169


Change subject: KUDU-2348: In the Java client, pick a random replica when no replica is local
......................................................................

KUDU-2348: In the Java client, pick a random replica when no replica is local

In RemoteTablet.java, 'getClosestServerInfo' always returns the last server
in hashmap iteration order, which may cause load to be concentrated
on one server especially when the number of tablet servers is small.

This commit use a more random approach to select server.

The current situation is: when the client chooses a replica to scan,
and there are no local replicas, it chooses whichever server ends up
last in the map iteration order, every time. So the choice is determined
by the set of UUIDs of tablet servers hosting replicas and implementation
details: the map implementation (consider if we used a TreeMap instead
of a hashmap) and possibly the history of the map instance.
As the issue said, this is bad because it could be the same across many
client instances talking to the cluster.

The new situation is: when the client chooses a replica to scan,
and there are no replicas to scan, it chooses one based on the first
character of the tablet id and the map iteration order. For a fixed tablet,
different clients will make the same choice of server assuming they have
the same map iteration order. This is an improvement over the current
situation, but there is still the possibility for clients to pile on to
one server for all the scans of a particular tablet.

A complete solution to the problem would remove the map iteration order
as a factor and choose a server at random without regard for tablet id,
so clients will scan different servers for the same tablet even if their
'tabletServers' map instances have exactly the same state.
Unfortunately, that's trickier, because right now the Java client is
dependent on 'getClosestServerInfo' returning the same choice for the
same set of tablet servers.
See 'testGetReplicaSelectedServerInfoDeterminism' in TestRemoteTablet.java.

Change-Id: I93ba846bd7140f577be32bd7424121c9ccabbfe0
---
M java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java
M java/kudu-client/src/test/java/org/apache/kudu/client/TestRemoteTablet.java
2 files changed, 30 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/69/12169/1
-- 
To view, visit http://gerrit.cloudera.org:8080/12169
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I93ba846bd7140f577be32bd7424121c9ccabbfe0
Gerrit-Change-Number: 12169
Gerrit-PatchSet: 1
Gerrit-Owner: Zhang Yifan <zh...@xiaomi.com>

[kudu-CR] KUDU-2348: In the Java client, pick a random replica when no replica is local

Posted by "Zhang Yifan (Code Review)" <ge...@cloudera.org>.
Zhang Yifan has abandoned this change. ( http://gerrit.cloudera.org:8080/12169 )

Change subject: KUDU-2348: In the Java client, pick a random replica when no replica is local
......................................................................


Abandoned
-- 
To view, visit http://gerrit.cloudera.org:8080/12169
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: abandon
Gerrit-Change-Id: I93ba846bd7140f577be32bd7424121c9ccabbfe0
Gerrit-Change-Number: 12169
Gerrit-PatchSet: 1
Gerrit-Owner: Zhang Yifan <zh...@xiaomi.com>
Gerrit-Reviewer: Kudu Jenkins (120)