mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
Support external versioning for deletes arriving before initial update, closes #1351.
This commit is contained in:
parent
8d7aaa704a
commit
d76d7d4a56
@ -634,7 +634,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||||||
updatedVersion = currentVersion < 0 ? 1 : currentVersion + 1;
|
updatedVersion = currentVersion < 0 ? 1 : currentVersion + 1;
|
||||||
} else { // External
|
} else { // External
|
||||||
if (currentVersion == -1) {
|
if (currentVersion == -1) {
|
||||||
throw new VersionConflictEngineException(shardId, delete.type(), delete.id(), -1, delete.version());
|
// its an external version, that's fine, we allow it to be set
|
||||||
|
//throw new VersionConflictEngineException(shardId, delete.type(), delete.id(), -1, delete.version());
|
||||||
} else if (currentVersion >= delete.version()) {
|
} else if (currentVersion >= delete.version()) {
|
||||||
throw new VersionConflictEngineException(shardId, delete.type(), delete.id(), currentVersion, delete.version());
|
throw new VersionConflictEngineException(shardId, delete.type(), delete.id(), currentVersion, delete.version());
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,24 @@ public class SimpleVersioningTests extends AbstractNodesTests {
|
|||||||
closeAllNodes();
|
closeAllNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test public void testExternalVersioningInitialDelete() throws Exception {
|
||||||
|
client.admin().indices().prepareDelete().execute().actionGet();
|
||||||
|
|
||||||
|
client.admin().indices().prepareCreate("test").execute().actionGet();
|
||||||
|
client.admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet();
|
||||||
|
|
||||||
|
DeleteResponse deleteResponse = client2.prepareDelete("test", "type", "1").setVersion(17).setVersionType(VersionType.EXTERNAL).execute().actionGet();
|
||||||
|
assertThat(deleteResponse.notFound(), equalTo(true));
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(13).setVersionType(VersionType.EXTERNAL).execute().actionGet();
|
||||||
|
} catch (ElasticSearchException e) {
|
||||||
|
assertThat(e.unwrapCause(), instanceOf(VersionConflictEngineException.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
client.prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(18).setVersionType(VersionType.EXTERNAL).execute().actionGet();
|
||||||
|
}
|
||||||
|
|
||||||
@Test public void testExternalVersioning() throws Exception {
|
@Test public void testExternalVersioning() throws Exception {
|
||||||
try {
|
try {
|
||||||
client.admin().indices().prepareDelete("test").execute().actionGet();
|
client.admin().indices().prepareDelete("test").execute().actionGet();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user