Skip to content

Commit 4e0d6d3

Browse files
authored
Correctly resolve type for delete operations (#72809)
#62616 refactored how we deal with building mapping updates for delete operations against an empty index. In 7x, delete operations include a type as part of the operation UID, and this type needs to be resolved against mappings. In particular, the type _doc can mean either a type called _doc (the general case), or it can mean whatever type this index actually has. There are two code paths in IndexShard.applyDeleteOperation, one for empty mappings and one for the standard case; #62616 was resolving the type for the first code path, but not the second, which meant that some delete operations could be written to the translog with an incorrect type. This commit adds type resolution to the second code path as well. Fixes #72735
1 parent d3c26fd commit 4e0d6d3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,9 @@ private Engine.DeleteResult applyDeleteOperation(Engine engine, long seqNo, long
980980
mapperService.mappingLookup().getType() + "]");
981981
}
982982
final Term uid = new Term(IdFieldMapper.NAME, Uid.encodeId(id));
983-
final Engine.Delete delete = prepareDelete(type, id, uid, seqNo, opPrimaryTerm, version,
983+
final Engine.Delete delete = prepareDelete(resolvedType, id, uid, seqNo, opPrimaryTerm, version,
984984
versionType, origin, ifSeqNo, ifPrimaryTerm);
985+
assert Objects.equals(resolvedType, delete.type());
985986
return delete(engine, delete);
986987
}
987988

0 commit comments

Comments
 (0)