From c34088ef421acf52cbef5e6835fcbecabd318f77 Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Wed, 29 Apr 2020 15:59:22 +0200 Subject: Add feature flag for enabling three phase updates --- .../java/com/yahoo/config/model/api/ModelContext.java | 2 ++ .../com/yahoo/config/model/deploy/TestProperties.java | 7 +++++++ .../yahoo/vespa/model/content/DistributorCluster.java | 8 ++++++-- .../yahoo/vespa/model/content/ContentClusterTest.java | 16 ++++++++++++++++ .../vespa/config/server/deploy/ModelContextImpl.java | 8 ++++++++ flags/src/main/java/com/yahoo/vespa/flags/Flags.java | 6 ++++++ 6 files changed, 45 insertions(+), 2 deletions(-) diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java index 8d4b8549e50..afa4000f891 100644 --- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java @@ -90,6 +90,8 @@ public interface ModelContext { boolean useDistributorBtreeDb(); + boolean useThreePhaseUpdates(); + // TODO: Remove once there are no Vespa versions below 7.170 boolean useBucketSpaceMetric(); diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java index 475b69c93c2..24cf892c49a 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java @@ -42,6 +42,7 @@ public class TestProperties implements ModelContext.Properties { private boolean useAdaptiveDispatch = false; private double topKProbability = 1.0; private boolean useDistributorBtreeDb = false; + private boolean useThreePhaseUpdates = false; private double defaultTermwiseLimit = 1.0; private double softStartSeconds = 0.0; private double threadPoolSizeFactor = 0.0; @@ -84,6 +85,7 @@ public class TestProperties implements ModelContext.Properties { @Override public double defaultTopKProbability() { return topKProbability; } @Override public boolean useDistributorBtreeDb() { return useDistributorBtreeDb; } + @Override public boolean useThreePhaseUpdates() { return useThreePhaseUpdates; } @Override public boolean useBucketSpaceMetric() { return true; } @Override public Optional athenzDomain() { return Optional.ofNullable(athenzDomain); } @@ -102,6 +104,11 @@ public class TestProperties implements ModelContext.Properties { return this; } + public TestProperties setUseThreePhaseUpdates(boolean useThreePhaseUpdates) { + this.useThreePhaseUpdates = useThreePhaseUpdates; + return this; + } + public TestProperties setSoftStartSeconds(double softStartSeconds) { this.softStartSeconds = softStartSeconds; return this; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java index 42d20b675a6..0b6b7154a62 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java @@ -42,6 +42,7 @@ public class DistributorCluster extends AbstractConfigProducer impl private final GcOptions gc; private final boolean hasIndexedDocumentType; private final boolean useBtreeDatabase; + private final boolean useThreePhaseUpdates; public static class Builder extends VespaDomBuilder.DomConfigProducerBuilder { @@ -103,16 +104,17 @@ public class DistributorCluster extends AbstractConfigProducer impl final GcOptions gc = parseGcOptions(documentsNode); final boolean hasIndexedDocumentType = clusterContainsIndexedDocumentType(documentsNode); boolean useBtreeDb = deployState.getProperties().useDistributorBtreeDb(); + boolean useThreePhaseUpdates = deployState.getProperties().useThreePhaseUpdates(); return new DistributorCluster(parent, new BucketSplitting.Builder().build(new ModelElement(producerSpec)), gc, - hasIndexedDocumentType, useBtreeDb); + hasIndexedDocumentType, useBtreeDb, useThreePhaseUpdates); } } private DistributorCluster(ContentCluster parent, BucketSplitting bucketSplitting, GcOptions gc, boolean hasIndexedDocumentType, - boolean useBtreeDatabase) + boolean useBtreeDatabase, boolean useThreePhaseUpdates) { super(parent, "distributor"); this.parent = parent; @@ -120,6 +122,7 @@ public class DistributorCluster extends AbstractConfigProducer impl this.gc = gc; this.hasIndexedDocumentType = hasIndexedDocumentType; this.useBtreeDatabase = useBtreeDatabase; + this.useThreePhaseUpdates = useThreePhaseUpdates; } @Override @@ -132,6 +135,7 @@ public class DistributorCluster extends AbstractConfigProducer impl builder.enable_revert(parent.getPersistence().supportRevert()); builder.disable_bucket_activation(hasIndexedDocumentType == false); builder.use_btree_database(useBtreeDatabase); + builder.enable_metadata_only_fetch_phase_for_inconsistent_updates(useThreePhaseUpdates); bucketSplitting.getConfig(builder); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java index 0e8bd0a41f1..802082cc2ff 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java @@ -988,4 +988,20 @@ public class ContentClusterTest extends ContentBaseTest { assertTrue(resolveDistributorBtreeDbConfigWithFeatureFlag(true)); } + private boolean resolveThreePhaseUpdateConfigWithFeatureFlag(boolean flagEnableThreePhase) { + VespaModel model = createEnd2EndOneNode(new TestProperties().setUseThreePhaseUpdates(flagEnableThreePhase)); + + ContentCluster cc = model.getContentClusters().get("storage"); + var builder = new StorDistributormanagerConfig.Builder(); + cc.getDistributorNodes().getConfig(builder); + + return (new StorDistributormanagerConfig(builder)).enable_metadata_only_fetch_phase_for_inconsistent_updates(); + } + + @Test + public void default_distributor_three_phase_update_config_controlled_by_properties() { + assertFalse(resolveThreePhaseUpdateConfigWithFeatureFlag(false)); + assertTrue(resolveThreePhaseUpdateConfigWithFeatureFlag(true)); + } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java index 08ae4216aaa..61ecfa16f66 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java @@ -152,6 +152,7 @@ public class ModelContextImpl implements ModelContext { private final boolean useAdaptiveDispatch; private final double defaultTopKprobability; private final boolean useDistributorBtreeDb; + private final boolean useThreePhaseUpdates; private final Optional endpointCertificateSecrets; private final double defaultTermwiseLimit; private final double defaultSoftStartSeconds; @@ -195,6 +196,8 @@ public class ModelContextImpl implements ModelContext { .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); useDistributorBtreeDb = Flags.USE_DISTRIBUTOR_BTREE_DB.bindTo(flagSource) .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); + useThreePhaseUpdates = Flags.USE_THREE_PHASE_UPDATES.bindTo(flagSource) + .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); threadPoolSizeFactor = Flags.DEFAULT_THREADPOOL_SIZE_FACTOR.bindTo(flagSource) .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); queueSizefactor = Flags.DEFAULT_QUEUE_SIZE_FACTOR.bindTo(flagSource) @@ -275,6 +278,11 @@ public class ModelContextImpl implements ModelContext { return useDistributorBtreeDb; } + @Override + public boolean useThreePhaseUpdates() { + return useThreePhaseUpdates; + } + // TODO: Remove @Override public boolean useBucketSpaceMetric() { return true; } diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java index 881c3a7dca6..155d2644095 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java @@ -172,6 +172,12 @@ public class Flags { "Takes effect at restart of distributor process", ZONE_ID, APPLICATION_ID); + public static final UnboundBooleanFlag USE_THREE_PHASE_UPDATES = defineFeatureFlag( + "use-three-phase-updates", false, + "Whether to enable the use of three-phase updates when bucket replicas are out of sync.", + "Takes effect at redeployment", + ZONE_ID, APPLICATION_ID); + public static final UnboundBooleanFlag HOST_HARDENING = defineFeatureFlag( "host-hardening", false, "Whether to enable host hardening Linux baseline.", -- cgit v1.2.3