Causal Consistency and Java Driver

I have some java code that deletes some documents and then writes new ones.
The deleted documents do not necessarily have the same _id as the new ones, but they may have.

I wrote this code:

try (ClientSession clientSession = mongoClient.startSession(ClientSessionOptions.builder().causallyConsistent(true).build())) {
  newCollection.withWriteConcern(WriteConcern.MAJORITY).deleteMany(clientSession, Filters.eq(INSTANCEID_FIELD_NAME, instanceId));
  newCollection.withWriteConcern(WriteConcern.MAJORITY).bulkWrite(clientSession, bulkInserts, new BulkWriteOptions().ordered(false));
}

the code generally works, but sometimes under stress I can get a

E11000 duplicate key error collection

how is it possible? did i write the Causal Consistency correctly in java?

Thanks.