[
https://issues.apache.org/jira/browse/HDFS-13795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16574540#comment-16574540
]
Kasper Janssens commented on HDFS-13795:
----------------------------------------
Hey Virajith,
How did we get the NPE for the aliasmap triggered? I agree that we protected
ourselves against Block or ProvidedStorageLocation being null, but as Ewan
commented I am not sure that we should mislead users when there is (according
to me) clearly a config issue. The thing is I don't see how we ended up in a
situation where the alias map server is being used but the alias map inside
that server is null.
If I look at this snippet then as soon as the alias map server is started the
setConf will be called.
{code:java}
private void startAliasMapServerIfNecessary(Configuration conf)
throws IOException {
if (conf.getBoolean(DFSConfigKeys.DFS_NAMENODE_PROVIDED_ENABLED,
DFSConfigKeys.DFS_NAMENODE_PROVIDED_ENABLED_DEFAULT)
&& conf.getBoolean(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_INMEMORY_ENABLED,
DFSConfigKeys.DFS_PROVIDED_ALIASMAP_INMEMORY_ENABLED_DEFAULT)) {
levelDBAliasMapServer = new InMemoryLevelDBAliasMapServer(
InMemoryAliasMap::init, namesystem.getBlockPoolId());
levelDBAliasMapServer.setConf(conf);
levelDBAliasMapServer.start();
}
}
{code}
And as soon as the setConf is called the alias map constructor passed into the
server constructor will be called.
{code:java}
@Override
public void setConf(Configuration conf) {
this.conf = conf;
try {
this.aliasMap = initFun.apply(conf, blockPoolId);
} catch (IOException e) {
throw new RuntimeException(e);
}
}{code}
I will not paste the static init function as well, but as far as I can see the
aliasmap should be initialized OR an IO exception should have been thrown
during initialization. So I am not sure in which case we get the NPE on alias
map and because of that I am not sure how we best protect ourselves against it.
I think it is dangerous to pretend all is well when it clearly isn't. The
developer who will debug through this is going to hate us thoroughly when he
finds out why his read always returns empty;)
Kasper
> Fix potential NPE in InMemoryLevelDBAliasMapServer
> --------------------------------------------------
>
> Key: HDFS-13795
> URL: https://issues.apache.org/jira/browse/HDFS-13795
> Project: Hadoop HDFS
> Issue Type: Bug
> Reporter: Virajith Jalaparti
> Assignee: Virajith Jalaparti
> Priority: Major
> Attachments: HDFS-13795.001.patch, HDFS-13795.002.patch,
> HDFS-13795.003.patch, HDFS-13795.004.patch
>
>
> Namenode fails to stop correctly due to NPE in InMemoryAliasMapServer, when
> it is configured incorrectly.
> {code:java}
> java.lang.NullPointerException
> at
> org.apache.hadoop.hdfs.server.aliasmap.InMemoryLevelDBAliasMapServer.close(InMemoryLevelDBAliasMapServer.java:149)
> at
> org.apache.hadoop.hdfs.server.namenode.NameNode.stop(NameNode.java:1023)
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]