bug fix for lookup leak when we remove the last lookup from lookup tier (#8598)

* bug fix for lookup leak when we remove the last lookup from lookup tier

* warnings about lookups that will never be loaded

* fix unit test
This commit is contained in:
Faxian Zhao 2019-09-27 18:55:02 +08:00 committed by Himanshu
parent a2363b6b61
commit e1b4a3ab71
2 changed files with 20 additions and 5 deletions

View File

@ -557,16 +557,27 @@ public class LookupCoordinatorManager
try {
List<ListenableFuture<Map.Entry>> futures = new ArrayList<>();
for (Map.Entry<String, Map<String, LookupExtractorFactoryMapContainer>> tierEntry : allLookupTiers.entrySet()) {
LOG.debug("Starting lookup mgmt for tier [%s].", tierEntry.getKey());
Set<String> discoveredLookupTiers = lookupNodeDiscovery.getAllTiers();
final Map<String, LookupExtractorFactoryMapContainer> tierLookups = tierEntry.getValue();
for (final HostAndPortWithScheme node : lookupNodeDiscovery.getNodesInTier(tierEntry.getKey())) {
// Check and Log warnings about lookups configured by user in DB but no nodes discovered to load those.
for (String tierInDB : allLookupTiers.keySet()) {
if (!discoveredLookupTiers.contains(tierInDB) &&
!allLookupTiers.getOrDefault(tierInDB, ImmutableMap.of()).isEmpty()) {
LOG.warn("Found lookups for tier [%s] in DB, but no nodes discovered for it", tierInDB);
}
}
for (String tier : discoveredLookupTiers) {
LOG.debug("Starting lookup mgmt for tier [%s].", tier);
final Map<String, LookupExtractorFactoryMapContainer> tierLookups = allLookupTiers.getOrDefault(tier, ImmutableMap.of());
for (final HostAndPortWithScheme node : lookupNodeDiscovery.getNodesInTier(tier)) {
LOG.debug(
"Starting lookup mgmt for tier [%s] and host [%s:%s:%s].",
tierEntry.getKey(),
tier,
node.getScheme(),
node.getHostText(),
node.getPort()

View File

@ -1138,6 +1138,10 @@ public class LookupCoordinatorManagerTest
HostAndPortWithScheme host2 = HostAndPortWithScheme.fromParts("http", "host2", 3456);
EasyMock.reset(lookupNodeDiscovery);
EasyMock
.expect(lookupNodeDiscovery.getAllTiers())
.andReturn(ImmutableSet.of("tier1"))
.once();
EasyMock
.expect(lookupNodeDiscovery.getNodesInTier("tier1"))
.andReturn(ImmutableList.of(host1, host2))