When trying to add multiple partitions, but one of them cannot be created successfully, none of the partitions are created, but the folders might not be cleaned up properly. See the test case "testAddPartitionsOneInvalid" in the TestAddPartitions test.
This is the problematic code in the HiveMetaStore.add_partitions_core method:
When going through the partitions, let's say for the first two partitions the threads are successfully submitted to create the folders. But an exception occurs for the third partition in the code before submitting the thread. (It can happen if the partition has different table or db name as the others or it has invalid value.)
In this case the execution will jump to the finally part where the folders in the "addedPartitions" map will be cleaned up. However it can happen that the threads for the first two partitions are not finished with the folder creation yet, so the map can be empty or it can contain only one of the partitions.
This issue also happens in the HiveMetastore.add_partitions_pspec_core method, as this code part is the same as in the add_partitions_core method.