Skip to main content
Currently, PCK provides several commands to check the consistency between the Pulsar and the storage, including the BookKeeper and the tiered storage (GCS, AWS). This document guides you how to find orphan ledgers, detect missing ledgers, delete under-replicated ledgers, and load inactive topics.

Detect missing ledgers

PCK gets all ledgers from a topic and then tries to find them in the storage. If a ledger is not found in the storage, the missing ledger is output on the terminal. You can use the detect-missing-ledger command to detect the ledger that exists in the Pulsar metadata but not in the Bookie or the tiered storage.

Detect missing ledgers from Bookie

You can use the sn-pulsar-tools pck bookie detect-missing-ledger [options] command to detect the missing ledgers from the Bookie. This table lists available options for the sn-pulsar-tools pck bookie detect-missing-ledger command. This example shows how to detect missing ledgers in the example topic of a locally-deployed cluster. Input
The output is similar to: Output

Detect missing ledgers from tiered storage

You can use the sn-pulsar-tools pck ts detect-missing-ledger [options] command to detect the missing ledgers from the tiered storage. This table lists available options for the sn-pulsar-tools pck ts detect-missing-ledger command.
If it is not a public bucket, you need to configure the credentials before executing the command.
  • For GCS, you need to configure the GOOGLE_CLOUD_PROJECT_ID and GOOGLE_CLOUD_SERVICE_ACCOUNT_KEYFILE as the environment variables. For example, if the bucket located in the project affable-ray-226821 and the key file path is /pulsar/key.json, you need to configure them as below:
This example shows how to detect missing ledgers in the example topic of a locally-deployed cluster. Input
The output is similar to: Output

Find orphan ledgers

PCK fetches the topic ledger information from the ZooKeeper and gets the range of the ledgers from the storage. Then, PCK compares them to find the orphan ledger that is not used in that topic. You can use the find-orphan-ledger command to find the orphan ledger that is not used in the Pulsar topic.
  • The find-orphan-ledger command is only available for Pulsar 2.3.0 or higher.
  • The find-orphan-ledger command is suitable for a Pulsar cluster that has a specific BookKeeper cluster. If multiple Pulsar clusters use the same BookKeeper cluster, do not use this command.

Find orphan ledgers from Bookie

You can use the sn-pulsar-tools pck bookie find-orphan-ledger [options] command to find the missing ledgers from the Bookie. This table lists available options for the sn-pulsar-tools pck bookie find-orphan-ledger command.
  • This example shows how to find orphan ledgers from the Bookie of a locally-deployed cluster. Input
    The output is similar to: Output
    365 is the orphan ledger and [] is the metadata of the ledger.
  • This example shows how to delete orphan ledgers from the Bookie of a locally-deployed cluster. Input
    The output is similar to: Output

Find orphan ledgers from tiered storage

You can use the sn-pulsar-tools pck ts find-orphan-ledger [options] command to find the missing ledgers from the tiered storage. This table outlines available options for the sn-pulsar-tools pck ts find-orphan-ledger command.
If it is not a public bucket, you need to configure the credentials before executing the command.
  • For GCS, you need to configure the GOOGLE_CLOUD_PROJECT_ID and GOOGLE_CLOUD_SERVICE_ACCOUNT_KEYFILE as the environment variables. For example, if the bucket located in the project affable-ray-226821 and the key file path is /pulsar/key.json, you need to configure them as below:
This example shows how to find orphan ledgers in the GCS. Input
The output is similar to: Output

Delete under-replicated ledgers from the Bookie

You can use the sn-pulsar-tools bookie delete-underreplicate-ledgers [options] command to delete the under-replicated ledgers from the Bookie. This table outlines available options for the sn-pulsar-tools bookie delete-underreplicate-ledgers command. This example shows how to delete under-replicated ledgers from the Bookie. Input
The output is similar to: Output
If you remove the --dry-run option, the output is similar to: Output

Load inactive topics

You can use the sn-pulsar-tools topics load-inactive-topic [options] command to load the inactive topics in the Pulsar broker. After loading, the Pulsar broker will check the ConsumedLedgers in every topic. This helps delete data that has already reached the retention limit. This table outlines available options for the sn-pulsar-tools topics load-inactive-topic command. This example shows how to load inactive topics for a locally-deployed cluster.
The output is similar to: Output