Skip to content

Commit

Permalink
Reduce deprecation warnings from bulk OCC (#53911)
Browse files Browse the repository at this point in the history
Bulk optimistic concurrency control would emit a deprecation warning header
per bulk item using internal versioning for OCC. However, for applications
that have not yet been upgraded, this can lead to significant performance
issues. Also, delete and update by query can be significantly affected if
the indices were created and data indexed into them on a pre-6.x version.
  • Loading branch information
henningandersen committed Mar 21, 2020
1 parent 2671530 commit d7eb23d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void testDelete() throws IOException {
deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
expectWarnings("Usage of internal versioning for optimistic concurrency control is deprecated and will be removed." +
" Please use the `if_seq_no` and `if_primary_term` parameters instead." +
" (request for index [index], type [type], id [id])"));
" (request for index [index], type [type])"));
} else {
deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
highLevelClient()::delete, highLevelClient()::deleteAsync);
Expand Down Expand Up @@ -156,7 +156,7 @@ public void testDelete() throws IOException {
execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
expectWarnings("Usage of internal versioning for optimistic concurrency control is deprecated and will be removed."
+ " Please use the `if_seq_no` and `if_primary_term` parameters instead."
+ " (request for index [index], type [type], id [version_conflict])"));
+ " (request for index [index], type [type])"));
} else {
execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
highLevelClient()::delete, highLevelClient()::deleteAsync);
Expand Down Expand Up @@ -507,7 +507,7 @@ public void testIndex() throws IOException {
execute(wrongRequest, highLevelClient()::index, highLevelClient()::indexAsync,
expectWarnings("Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. "
+ "Please use the `if_seq_no` and `if_primary_term` parameters instead. "
+ "(request for index [index], type [type], id [id])"));
+ "(request for index [index], type [type])"));
} else {
execute(wrongRequest, highLevelClient()::index, highLevelClient()::indexAsync,
highLevelClient()::index, highLevelClient()::indexAsync);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
{ "doc": { "f1": "v2" } }
warnings:
- "Deprecated field [_version] used, expected [version] instead"
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_index], type [test_type], id [test_id_1])"
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_index], type [test_type], id [test_id_2])"
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_index], type [test_type])"

- do:
bulk:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
id: 1
version: 2
warnings:
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test], id [1])"
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test])"

- do:
delete:
Expand All @@ -31,6 +31,6 @@
id: 1
version: 1
warnings:
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test], id [1])"
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test])"

- match: { _version: 2 }
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
body: { foo: bar }
version: 1
warnings:
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test], id [1])"
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test])"

- do:
index:
Expand All @@ -41,6 +41,6 @@
body: { foo: bar }
version: 2
warnings:
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test], id [1])"
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test])"

- match: { _version: 3 }
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
body:
doc: { foo: baz }
warnings:
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test], id [1])"
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test])"

- do:
index:
Expand All @@ -35,4 +35,4 @@
body:
doc: { foo: baz }
warnings:
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test], id [1])"
- "Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test_1], type [test])"
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ private static void validateDocWriteRequest(DocWriteRequest<?> request, boolean
&& request.version() != Versions.MATCH_DELETED) {
DEPRECATION_LOGGER.deprecatedAndMaybeLog("occ_internal_version",
"Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use" +
" the `if_seq_no` and `if_primary_term` parameters instead. (request for index [{}], type [{}], id [{}])",
request.index(), request.type(), request.id());
" the `if_seq_no` and `if_primary_term` parameters instead. (request for index [{}], type [{}])",
request.index(), request.type());
}
} else {
if (request.ifSeqNo() != SequenceNumbers.UNASSIGNED_SEQ_NO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -853,10 +853,9 @@ public void testDeprecationCASUsingVersion() throws Exception {
threadPool::absoluteTimeInMillis, new NoopMappingUpdatePerformer(), () -> {});
closeShards(shard);
if (deprecatedRequestIds.isEmpty() == false) {
assertWarnings(deprecatedRequestIds.stream().map(id ->
assertWarnings(
"Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. Please use the " +
"`if_seq_no` and `if_primary_term` parameters instead. (request for index [index], type [_doc], id [" + id + "])")
.toArray(String[]::new));
"`if_seq_no` and `if_primary_term` parameters instead. (request for index [index], type [_doc])");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public void testRequestFailureReplication() throws Exception {
indexShard.translogStats().estimatedNumberOfOperations(), equalTo(0));
}
assertWarnings("Usage of internal versioning for optimistic concurrency control is deprecated and will be removed. " +
"Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test], type [type], id [1])");
"Please use the `if_seq_no` and `if_primary_term` parameters instead. (request for index [test], type [type])");
}
}

Expand Down

0 comments on commit d7eb23d

Please sign in to comment.