Add debug logging to help diagnose intermittent upgrade test failures.

Also fixed indentation in ElasticsearchMergePolicy.
This commit is contained in:
Ryan Ernst 2014-10-15 13:41:28 -07:00
parent 516b87e129
commit 5ed193086d
2 changed files with 46 additions and 31 deletions

View File

@ -31,6 +31,8 @@ import org.apache.lucene.util.packed.GrowableWriter;
import org.apache.lucene.util.packed.PackedInts; import org.apache.lucene.util.packed.PackedInts;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.common.Numbers; import org.elasticsearch.common.Numbers;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import org.elasticsearch.index.mapper.internal.VersionFieldMapper; import org.elasticsearch.index.mapper.internal.VersionFieldMapper;
@ -54,6 +56,8 @@ import java.util.Map;
*/ */
public final class ElasticsearchMergePolicy extends MergePolicy { public final class ElasticsearchMergePolicy extends MergePolicy {
private static ESLogger logger = Loggers.getLogger(ElasticsearchMergePolicy.class);
private final MergePolicy delegate; private final MergePolicy delegate;
private volatile boolean upgradeInProgress; private volatile boolean upgradeInProgress;
private static final int MAX_CONCURRENT_UPGRADE_MERGES = 5; private static final int MAX_CONCURRENT_UPGRADE_MERGES = 5;
@ -208,16 +212,19 @@ public final class ElasticsearchMergePolicy extends MergePolicy {
cur.major == old.major && cur.minor > old.minor) { cur.major == old.major && cur.minor > old.minor) {
// TODO: Use IndexUpgradeMergePolicy instead. We should be comparing codecs, // TODO: Use IndexUpgradeMergePolicy instead. We should be comparing codecs,
// for now we just assume every minor upgrade has a new format. // for now we just assume every minor upgrade has a new format.
logger.debug("Adding segment " + info.info.name + " to be upgraded");
spec.add(new OneMerge(Lists.newArrayList(info))); spec.add(new OneMerge(Lists.newArrayList(info)));
} }
if (spec.merges.size() == MAX_CONCURRENT_UPGRADE_MERGES) { if (spec.merges.size() == MAX_CONCURRENT_UPGRADE_MERGES) {
// hit our max upgrades, so return the spec. we will get a cascaded call to continue. // hit our max upgrades, so return the spec. we will get a cascaded call to continue.
logger.debug("Returning " + spec.merges.size() + " merges for upgrade");
return spec; return spec;
} }
} }
// We must have less than our max upgrade merges, so the next return will be our last in upgrading mode. // We must have less than our max upgrade merges, so the next return will be our last in upgrading mode.
upgradeInProgress = false; upgradeInProgress = false;
if (spec.merges.isEmpty() == false) { if (spec.merges.isEmpty() == false) {
logger.debug("Return " + spec.merges.size() + " merges for end of upgrade");
return spec; return spec;
} }
// fall through, so when we don't have any segments to upgrade, the delegate policy // fall through, so when we don't have any segments to upgrade, the delegate policy

View File

@ -121,6 +121,8 @@ public class UpgradeTest extends ElasticsearchBackwardsCompatIntegrationTest {
assertNotUpgraded(httpClient, null); assertNotUpgraded(httpClient, null);
final String indexToUpgrade = "test" + randomInt(numIndexes - 1); final String indexToUpgrade = "test" + randomInt(numIndexes - 1);
logger.debug("Running upgrade on index " + indexToUpgrade);
logClusterState();
runUpgrade(httpClient, indexToUpgrade); runUpgrade(httpClient, indexToUpgrade);
awaitBusy(new Predicate<Object>() { awaitBusy(new Predicate<Object>() {
@Override @Override
@ -132,8 +134,14 @@ public class UpgradeTest extends ElasticsearchBackwardsCompatIntegrationTest {
} }
} }
}); });
logger.debug("Single index upgrade complete");
logClusterState();
logger.debug("Running upgrade on the rest of the indexes");
logClusterState();
runUpgrade(httpClient, null, "wait_for_completion", "true"); runUpgrade(httpClient, null, "wait_for_completion", "true");
logger.debug("Full upgrade complete");
logClusterState();
assertUpgraded(httpClient, null); assertUpgraded(httpClient, null);
} }