Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "force" version type #47228

Merged
merged 1 commit into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ static Request bulk(BulkRequest bulkRequest) throws IOException {
metadata.field("version_type", "external");
} else if (versionType == VersionType.EXTERNAL_GTE) {
metadata.field("version_type", "external_gte");
} else if (versionType == VersionType.FORCE) {
metadata.field("version_type", "force");
}
}

Expand Down
4 changes: 1 addition & 3 deletions docs/reference/docs/get.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ better GET scaling we will have.
===== Versioning support

You can use the `version` parameter to retrieve the document only if
its current version is equal to the specified one. This behavior is the same
for all version types with the exception of version type `FORCE` which always
retrieves the document. Note that `FORCE` version type is deprecated.
its current version is equal to the specified one.

Internally, Elasticsearch has marked the old document as deleted and added an
entirely new document. The old version of the document doesn’t disappear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public interface DocWriteRequest<T> extends IndicesRequest {
* @return the Request
*/
T defaultTypeIfNull(String defaultType);



/**
* Get the id of the document for this request
* @return the id
Expand Down Expand Up @@ -257,9 +256,6 @@ static ActionRequestValidationException validateSeqNoBasedCASParams(
validationException = addValidationError("illegal version value [" + version + "] for version type ["
+ versionType.name() + "]", validationException);
}
if (versionType == VersionType.FORCE) {
validationException = addValidationError("version type [force] may no longer be used", validationException);
}

if (versionType == VersionType.INTERNAL && version != Versions.MATCH_ANY && version != Versions.MATCH_DELETED) {
validationException = addValidationError("internal versioning can not be used for optimistic concurrency control. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ public ActionRequestValidationException validate() {
validationException = ValidateActions.addValidationError("illegal version value [" + version + "] for version type ["
+ versionType.name() + "]", validationException);
}
if (versionType == VersionType.FORCE) {
validationException = ValidateActions.addValidationError("version type [force] may no longer be used", validationException);
}
return validationException;
}

Expand Down
53 changes: 0 additions & 53 deletions server/src/main/java/org/elasticsearch/index/VersionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,55 +201,6 @@ public boolean validateVersionForReads(long version) {
return version >= 0L || version == Versions.MATCH_ANY;
}

},
/**
* Warning: this version type should be used with care. Concurrent indexing may result in loss of data on replicas
*
* @deprecated this will be removed in 7.0 and should not be used! It is *ONLY* for backward compatibility with 5.0 indices
*/
@Deprecated
FORCE((byte) 3) {
@Override
public boolean isVersionConflictForWrites(long currentVersion, long expectedVersion, boolean deleted) {
if (currentVersion == Versions.NOT_FOUND) {
return false;
}
if (expectedVersion == Versions.MATCH_ANY) {
throw new IllegalStateException("you must specify a version when use VersionType.FORCE");
}
return false;
}

@Override
public String explainConflictForWrites(long currentVersion, long expectedVersion, boolean deleted) {
throw new AssertionError("VersionType.FORCE should never result in a write conflict");
}

@Override
public boolean isVersionConflictForReads(long currentVersion, long expectedVersion) {
return false;
}

@Override
public String explainConflictForReads(long currentVersion, long expectedVersion) {
throw new AssertionError("VersionType.FORCE should never result in a read conflict");
}

@Override
public long updateVersion(long currentVersion, long expectedVersion) {
return expectedVersion;
}

@Override
public boolean validateVersionForWrites(long version) {
return version >= 0L;
}

@Override
public boolean validateVersionForReads(long version) {
return version >= 0L || version == Versions.MATCH_ANY;
}

};

private final byte value;
Expand Down Expand Up @@ -335,8 +286,6 @@ public static VersionType fromString(String versionType) {
return EXTERNAL;
} else if ("external_gte".equals(versionType)) {
return EXTERNAL_GTE;
} else if ("force".equals(versionType)) {
return FORCE;
}
throw new IllegalArgumentException("No version type match [" + versionType + "]");
}
Expand All @@ -359,8 +308,6 @@ public static VersionType fromValue(byte value) {
return EXTERNAL;
} else if (value == 2) {
return EXTERNAL_GTE;
} else if (value == 3) {
return FORCE;
}
throw new IllegalArgumentException("No version type match [" + value + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ public void testVersioningCreateExistsException() throws IOException {

public void testOutOfOrderDocsOnReplica() throws IOException {
final List<Engine.Operation> ops = generateSingleDocHistory(true,
randomFrom(VersionType.INTERNAL, VersionType.EXTERNAL, VersionType.EXTERNAL_GTE, VersionType.FORCE),
randomFrom(VersionType.INTERNAL, VersionType.EXTERNAL, VersionType.EXTERNAL_GTE),
2, 2, 20, "1");
assertOpsOnReplica(ops, replicaEngine, true, logger);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,6 @@ public static List<Engine.Operation> generateSingleDocHistory(boolean forReplica
case EXTERNAL_GTE:
version = randomBoolean() ? Math.max(i - 1, 0) : i;
break;
case FORCE:
version = randomNonNegativeLong();
break;
default:
throw new UnsupportedOperationException("unknown version type: " + versionType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void testOutOfOrderDocuments() throws IOException {
final EngineConfig engineConfig = engineConfig(shardId, indexSettings, threadPool, store, logger, xContentRegistry());
try (FollowingEngine followingEngine = createEngine(store, engineConfig)) {
final VersionType versionType =
randomFrom(VersionType.INTERNAL, VersionType.EXTERNAL, VersionType.EXTERNAL_GTE, VersionType.FORCE);
randomFrom(VersionType.INTERNAL, VersionType.EXTERNAL, VersionType.EXTERNAL_GTE);
final List<Engine.Operation> ops = EngineTestCase.generateSingleDocHistory(true, versionType, 2, 2, 20, "id");
ops.stream().mapToLong(op -> op.seqNo()).max().ifPresent(followingEngine::advanceMaxSeqNoOfUpdatesOrDeletes);
EngineTestCase.assertOpsOnReplica(ops, followingEngine, true, logger);
Expand Down