Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pulsar-managed-ledger-admin] Fix deleting multiple ledgers (apache#9009
) ### Motivation There are 2 main problems in pulsar-managed-ledger-admin when deleting multiple ledgers - Removing a ledger while iterating through the ledger list will lead to skipping the next ledger in the list - Only the first attempt to change the zookeeper's data will succeed, the second will fail due to version error Logs for the second problem: ``` Traceback (most recent call last): File "/Users/milos/Downloads/pulsar/bin/pulsar-managed-ledger-admin", line 109, in deleteLedgerIdsFromManagedLedgerInfo zk.set(mlPath, updatedMlInfo, version=mlStat.version) File "/usr/local/lib/python3.9/site-packages/kazoo/client.py", line 1359, in set return self.set_async(path, value, version).get() File "/usr/local/lib/python3.9/site-packages/kazoo/handlers/utils.py", line 75, in get raise self._exception kazoo.exceptions.BadVersionError Failed to delete ledgerIds for /managed-ledgers/public/default/persistent/events-other due to BadVersionError() ``` ### Modifications Changed iterating through the loop with a while loop and index instead of foreach and handling index increment. Changed updating zookeeper's data only once when the loop is finished. ### Verifying this change - [x] Make sure that the change passes the CI checks.