In https://github.com/apache/bookkeeper/pull/2805, it introduces UnderReplicatedLedgersChangedCb to watch the zookeeper `underreplication` path. After a `underreplication` ledger mark is replicated, the UnderReplicatedLedgersChangedCb will call back.
In the callback, it will list all the `unnderreplication` ledgers to record the metrics `underReplicatedLedgersGuageValue`. It's a heavy operation for zookeeper. And in the pulsar, it introduces a deadlock after implementing the new API LedgerUnderreplicationManager#notifyUnderReplicationLedgerChanged in PulsarLedgerUnderreplicationManager. see https://github.com/apache/pulsar/pull/21010. I would suggest you remove underReplicatedLedgersChangedCb in Auditor. If the user wants to record the metrics, a scheduled task will be better than a zk watch event to trigger it.