Skip to content

Commit

Permalink
[fix](fe) Fix show frontends npt in some situations
Browse files Browse the repository at this point in the history
```
java.lang.NullPointerException: null
    at com.sleepycat.je.rep.util.ReplicationGroupAdmin.getMasterSocket(ReplicationGroupAdmin.java:191)
    at com.sleepycat.je.rep.util.ReplicationGroupAdmin.doMessageExchange(ReplicationGroupAdmin.java:607)
    at com.sleepycat.je.rep.util.ReplicationGroupAdmin.getGroup(ReplicationGroupAdmin.java:406)
    at org.apache.doris.ha.BDBHA.getElectableNodes(BDBHA.java:132)
    at org.apache.doris.common.proc.FrontendsProcNode.getFrontendsInfo(FrontendsProcNode.java:84)
    at org.apache.doris.qe.ShowExecutor.handleShowFrontends(ShowExecutor.java:1923)
    at org.apache.doris.qe.ShowExecutor.execute(ShowExecutor.java:355)
    at org.apache.doris.qe.StmtExecutor.handleShow(StmtExecutor.java:2113)
    ...
```
  • Loading branch information
SWJTU-ZhangLei committed Nov 20, 2023
1 parent 20d7ab0 commit e53a6ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public static void getFrontendsInfo(Env env, List<List<String>> infos) {
}

for (Frontend fe : env.getFrontends(null /* all */)) {

List<String> info = new ArrayList<String>();
info.add(fe.getNodeName());
info.add(fe.getHost());
Expand Down
10 changes: 6 additions & 4 deletions fe/fe-core/src/main/java/org/apache/doris/ha/BDBHA.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ public boolean fencing() {

@Override
public List<InetSocketAddress> getObserverNodes() {
List<InetSocketAddress> ret = new ArrayList<InetSocketAddress>();
ReplicationGroupAdmin replicationGroupAdmin = environment.getReplicationGroupAdmin();
if (replicationGroupAdmin == null) {
return null;
return ret;
}
List<InetSocketAddress> ret = new ArrayList<InetSocketAddress>();

try {
ReplicationGroup replicationGroup = replicationGroupAdmin.getGroup();
for (ReplicationNode replicationNode : replicationGroup.getSecondaryNodes()) {
Expand All @@ -123,11 +124,12 @@ public List<InetSocketAddress> getObserverNodes() {

@Override
public List<InetSocketAddress> getElectableNodes(boolean leaderIncluded) {
List<InetSocketAddress> ret = new ArrayList<InetSocketAddress>();
ReplicationGroupAdmin replicationGroupAdmin = environment.getReplicationGroupAdmin();
if (replicationGroupAdmin == null) {
return null;
return ret;
}
List<InetSocketAddress> ret = new ArrayList<InetSocketAddress>();

try {
ReplicationGroup replicationGroup = replicationGroupAdmin.getGroup();
for (ReplicationNode replicationNode : replicationGroup.getElectableNodes()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ public ReplicationGroupAdmin getReplicationGroupAdmin() {
.filter(Frontend::isAlive)
.map(fe -> new InetSocketAddress(fe.getHost(), fe.getEditLogPort()))
.collect(Collectors.toSet());

if (addresses.isEmpty()) {
LOG.info("addresses is empty");
return null;
}
return new ReplicationGroupAdmin(PALO_JOURNAL_GROUP, addresses);
}

Expand Down

0 comments on commit e53a6ab

Please sign in to comment.