Reduce Pulsar topic partitions by recreating the topic
Fewer partitions needs a new topic. Know what you lose before you agree.

The recording shows kurkik pulsar sync on the demo sandbox; its data differs from this example.
Without the extra flags
Section titled “Without the extra flags”What you get if you do not ask for the risky part:
$ kurkik pulsar sync a.yaml b --overwrite --dry-runSync a.yaml into b - Apache Pulsar, cluster b (http://pulsar-b:8080)owns: namespaces shop/orders - the ones its channels live in; permissions, as x-kurkik.pulsar.server.acl declares themplan: <digest>Run one sync per cluster at a time: two at once each plan against a state the other is changing.
Nothing to change.
left alone (2) needs recreating persistent://shop/orders/paid partitions --overwrite --force and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
0 changes - 1 still differsexit 2The plan
Section titled “The plan”Nothing changes yet. --dry-run only shows what would happen.
$ kurkik pulsar sync a.yaml b --overwrite --force --dry-runSync a.yaml into b - Apache Pulsar, cluster b (http://pulsar-b:8080)owns: namespaces shop/orders - the ones its channels live in; permissions, as x-kurkik.pulsar.server.acl declares themplan: <digest>Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (1) ± recreate persistent://shop/orders/paid partitions 4 -> 2 [destroys messages] Deleting persistent://shop/orders/paid and creating it as the document says loses every message in it and every subscription's position; the subscriptions the document lists are made again, at its end. note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed. note: A recreation deletes the topic and waits up to 60s for Pulsar to let go of its name; if the create fails after the delete, the rollback holds the topic's definition.
left alone (1) and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: tenant admin on shop
1 change, 1 destroy
Apache Pulsar has no rehearsal: the plan above is all of it. Nothing was changed.exit 2$ kurkik pulsar sync a.yaml b --overwrite --force --yesSync a.yaml into b - Apache Pulsar, cluster b (http://pulsar-b:8080)owns: namespaces shop/orders - the ones its channels live in; permissions, as x-kurkik.pulsar.server.acl declares themplan: <digest>Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (1) ± recreate persistent://shop/orders/paid partitions 4 -> 2 [destroys messages] Deleting persistent://shop/orders/paid and creating it as the document says loses every message in it and every subscription's position; the subscriptions the document lists are made again, at its end. note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed. note: A recreation deletes the topic and waits up to 60s for Pulsar to let go of its name; if the create fails after the delete, the rollback holds the topic's definition.
left alone (1) and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: tenant admin on shop
1 change, 1 destroy
applied [+] done recreate persistent://shop/orders/paid partitions 4 -> 2
Applied 1 of 1 change - 1 left alonesnapshot: ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yamlrollback: ~/.local/state/kurkik/sync/b/b-<time>.rollback.yamlundo: kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yamlexit 0Rollback file
Section titled “Rollback file”Written before the first change.
rollback.yaml
system: "Apache Pulsar"target: "b (http://pulsar-b:8080)"createdAt: "<time>"document: "~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml"entries:- forAction: "recreate-channel:persistent://shop/orders/paid" undo: "RESTORE_RECREATED_CHANNEL" target: "persistent://shop/orders/paid" field: "partitions" note: "sync recreated this. Going back recreates it again as it was, losing what\ \ was written since." definition: partitions: "4" persistent: "true"Check afterwards
Section titled “Check afterwards”$ kurkik pulsar diff a.yaml ba.yaml vs b
Notes - Broker settings that name a machine or a cluster were not compared: advertisedAddress, clusterName, metadataStoreUrl, statusFilePath. - Not compared: schemas. Add --schemas, or --all, to compare them.
Drift: 0 changed · 0 unmanaged · 0 missing (no drift) - 46 matchedexit 0Revert
Section titled “Revert”$ kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml b --force --yesRevert b to b-<time>.snapshot.yaml - Apache Pulsar, cluster b (http://pulsar-b:8080)owns: what the run being undone changed, as its rollback records itplan: <digest>Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (1) ± recreate persistent://shop/orders/paid partitions 2 partitions -> 4 partitions [destroys messages] Making persistent://shop/orders/paid again as it was loses every message written to it since. note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed. note: A recreation deletes the topic and waits up to 60s for Pulsar to let go of its name; if the create fails after the delete, the rollback holds the topic's definition.
applying needs: tenant admin on shop
1 change, 1 destroy
applied [+] done recreate persistent://shop/orders/paid partitions 2 partitions -> 4 partitions
Applied 1 of 1 changesnapshot: ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yamlrollback: ~/.local/state/kurkik/sync/b/b-<time>.rollback.yamlundo: kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yamlexit 0After the revert, compared with how it was before: Drift: 0 changed · 0 unmanaged · 0 missing (no drift) - 46 matched
The documents
Section titled “The documents”source.yaml, 184 lines
asyncapi: 3.0.0info: title: a Apache Pulsar API version: 1.0.0-SNAPSHOT description: Generated by reading Apache Pulsar of a (http://pulsar-a:8080).servers: standalone: host: pulsar-a:6650 protocol: pulsar protocolVersion: "4.0" description: Apache Pulsar cluster standalone. bindings: pulsar: bindingVersion: 0.1.0 tenant: shop x-kurkik: pulsar: server: cluster: standalone brokers: - localhost:8080 schemaRegistryUrl: http://pulsar-a:8080 schemaRegistryVendor: pulsar namespacePolicies: public/default: schema-autoupdate: "on" shop/orders: backlog-quota destination_storage: "limit 536870912 bytes, producer_request_hold" retention: timeInMinutes: 60 sizeInMB: 1024 schema-autoupdate: "on" tenants: - tenant: public adminRoles: [] allowedClusters: - standalone - tenant: shop adminRoles: - shop-admin allowedClusters: - standalone security: - security: NONE tls: false acl: [] consumers: [] producers: [] functions: [] sources: [] sinks: [] brokerConfiguration: advertisedAddress: localhost backlogQuotaDefaultLimitGB: "10.0" bookkeeperClientMinNumRacksPerWriteQuorum: "1" bookkeeperClientReorderReadSequenceEnabled: "false" bookkeeperNumberOfChannelsPerBookie: "1" brokerDeleteInactiveTopicsEnabled: "false" clusterName: standalone enablePackagesManagement: "true" forceDeleteNamespaceAllowed: "true" functionsWorkerEnablePackageManagement: "true" isRunningStandalone: "true" loadBalancerEnabled: "false" loadManagerClassName: org.apache.pulsar.broker.loadbalance.NoopLoadManager managedLedgerCacheEvictionFrequency: "100.0" managedLedgerDefaultAckQuorum: "1" managedLedgerDefaultEnsembleSize: "1" managedLedgerDefaultMarkDeleteRateLimit: "0.1" managedLedgerDefaultWriteQuorum: "1" metadataStoreUrl: rocksdb:///pulsar/data/metadata packagesManagementStorageProvider: org.apache.pulsar.packages.management.storage.filesystem.FileSystemPackagesStorageProvider statusFilePath: /usr/local/apache/htdocs topicPublisherThrottlingTickTimeMillis: "2" webSocketServiceEnabled: "true" clientConfiguration: serviceUrl: pulsar://pulsar-a:6650 webServiceUrl: http://pulsar-a:8080 producerConfiguration: {} consumerConfiguration: {}channels: persistent-shop-orders-created: address: persistent://shop/orders/created bindings: pulsar: bindingVersion: 0.1.0 namespace: orders persistence: persistent retention: time: 60 size: 1024 x-kurkik: pulsar: channel: topic: persistent://shop/orders/created tenant: shop namespace: orders persistence: persistent partitions: 0 geo-replication: - standalone retention: time: 60 size: 1024 topicConfiguration: backlog-quota destination_storage: "limit 536870912 bytes, producer_request_hold" partitions: 0 persistence: persistent replication-clusters: - standalone retention: timeInMinutes: 60 sizeInMB: 1024 schema-autoupdate: "on" persistent-shop-orders-paid: address: persistent://shop/orders/paid bindings: pulsar: bindingVersion: 0.1.0 namespace: orders persistence: persistent retention: time: 60 size: 1024 x-kurkik: pulsar: channel: topic: persistent://shop/orders/paid tenant: shop namespace: orders persistence: persistent partitions: 2 geo-replication: - standalone retention: time: 60 size: 1024 topicConfiguration: backlog-quota destination_storage: "limit 536870912 bytes, producer_request_hold" partitions: 2 persistence: persistent replication-clusters: - standalone retention: timeInMinutes: 60 sizeInMB: 1024 schema-autoupdate: "on"operations: receive_persistent-shop-orders-created: action: receive channel: $ref: "#/channels/persistent-shop-orders-created" x-kurkik: pulsar: operation: security: [] consumerConfiguration: {} receive_persistent-shop-orders-paid: action: receive channel: $ref: "#/channels/persistent-shop-orders-paid" x-kurkik: pulsar: operation: security: [] consumerConfiguration: {} send_persistent-shop-orders-created: action: send channel: $ref: "#/channels/persistent-shop-orders-created" x-kurkik: pulsar: operation: security: [] producerConfiguration: {} send_persistent-shop-orders-paid: action: send channel: $ref: "#/channels/persistent-shop-orders-paid" x-kurkik: pulsar: operation: security: [] producerConfiguration: {}target.yaml, 184 lines
asyncapi: 3.0.0info: title: b Apache Pulsar API version: 1.0.0-SNAPSHOT description: Generated by reading Apache Pulsar of b (http://pulsar-b:8080).servers: standalone: host: pulsar-b:6650 protocol: pulsar protocolVersion: "4.0" description: Apache Pulsar cluster standalone. bindings: pulsar: bindingVersion: 0.1.0 tenant: shop x-kurkik: pulsar: server: cluster: standalone brokers: - localhost:8080 schemaRegistryUrl: http://pulsar-b:8080 schemaRegistryVendor: pulsar namespacePolicies: public/default: schema-autoupdate: "on" shop/orders: backlog-quota destination_storage: "limit 536870912 bytes, producer_request_hold" retention: timeInMinutes: 60 sizeInMB: 1024 schema-autoupdate: "on" tenants: - tenant: public adminRoles: [] allowedClusters: - standalone - tenant: shop adminRoles: - shop-admin allowedClusters: - standalone security: - security: NONE tls: false acl: [] consumers: [] producers: [] functions: [] sources: [] sinks: [] brokerConfiguration: advertisedAddress: localhost backlogQuotaDefaultLimitGB: "10.0" bookkeeperClientMinNumRacksPerWriteQuorum: "1" bookkeeperClientReorderReadSequenceEnabled: "false" bookkeeperNumberOfChannelsPerBookie: "1" brokerDeleteInactiveTopicsEnabled: "false" clusterName: standalone enablePackagesManagement: "true" forceDeleteNamespaceAllowed: "true" functionsWorkerEnablePackageManagement: "true" isRunningStandalone: "true" loadBalancerEnabled: "false" loadManagerClassName: org.apache.pulsar.broker.loadbalance.NoopLoadManager managedLedgerCacheEvictionFrequency: "100.0" managedLedgerDefaultAckQuorum: "1" managedLedgerDefaultEnsembleSize: "1" managedLedgerDefaultMarkDeleteRateLimit: "0.1" managedLedgerDefaultWriteQuorum: "1" metadataStoreUrl: rocksdb:///pulsar/data/metadata packagesManagementStorageProvider: org.apache.pulsar.packages.management.storage.filesystem.FileSystemPackagesStorageProvider statusFilePath: /usr/local/apache/htdocs topicPublisherThrottlingTickTimeMillis: "2" webSocketServiceEnabled: "true" clientConfiguration: serviceUrl: pulsar://pulsar-b:6650 webServiceUrl: http://pulsar-b:8080 producerConfiguration: {} consumerConfiguration: {}channels: persistent-shop-orders-created: address: persistent://shop/orders/created bindings: pulsar: bindingVersion: 0.1.0 namespace: orders persistence: persistent retention: time: 60 size: 1024 x-kurkik: pulsar: channel: topic: persistent://shop/orders/created tenant: shop namespace: orders persistence: persistent partitions: 0 geo-replication: - standalone retention: time: 60 size: 1024 topicConfiguration: backlog-quota destination_storage: "limit 536870912 bytes, producer_request_hold" partitions: 0 persistence: persistent replication-clusters: - standalone retention: timeInMinutes: 60 sizeInMB: 1024 schema-autoupdate: "on" persistent-shop-orders-paid: address: persistent://shop/orders/paid bindings: pulsar: bindingVersion: 0.1.0 namespace: orders persistence: persistent retention: time: 60 size: 1024 x-kurkik: pulsar: channel: topic: persistent://shop/orders/paid tenant: shop namespace: orders persistence: persistent partitions: 4 geo-replication: - standalone retention: time: 60 size: 1024 topicConfiguration: backlog-quota destination_storage: "limit 536870912 bytes, producer_request_hold" partitions: 4 persistence: persistent replication-clusters: - standalone retention: timeInMinutes: 60 sizeInMB: 1024 schema-autoupdate: "on"operations: receive_persistent-shop-orders-created: action: receive channel: $ref: "#/channels/persistent-shop-orders-created" x-kurkik: pulsar: operation: security: [] consumerConfiguration: {} receive_persistent-shop-orders-paid: action: receive channel: $ref: "#/channels/persistent-shop-orders-paid" x-kurkik: pulsar: operation: security: [] consumerConfiguration: {} send_persistent-shop-orders-created: action: send channel: $ref: "#/channels/persistent-shop-orders-created" x-kurkik: pulsar: operation: security: [] producerConfiguration: {} send_persistent-shop-orders-paid: action: send channel: $ref: "#/channels/persistent-shop-orders-paid" x-kurkik: pulsar: operation: security: [] producerConfiguration: {}How to build this setup yourself
Clusters
Pulsar a
pulsar-admin --admin-url http://pulsar-a:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-adminpulsar-admin --admin-url http://pulsar-a:8080 namespaces create shop/orders --clusters standalonepulsar-admin --admin-url http://pulsar-a:8080 topics create persistent://shop/orders/createdpulsar-admin --admin-url http://pulsar-a:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 2pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-backlog-quota shop/orders --limit 512M --policy producer_request_hold --type destination_storagepulsar-admin --admin-url http://pulsar-a:8080 namespaces set-retention shop/orders --time 60m --size 1024MPulsar b
pulsar-admin --admin-url http://pulsar-b:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-adminpulsar-admin --admin-url http://pulsar-b:8080 namespaces create shop/orders --clusters standalonepulsar-admin --admin-url http://pulsar-b:8080 topics create persistent://shop/orders/createdpulsar-admin --admin-url http://pulsar-b:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 4pulsar-admin --admin-url http://pulsar-b:8080 namespaces set-backlog-quota shop/orders --limit 512M --policy producer_request_hold --type destination_storagepulsar-admin --admin-url http://pulsar-b:8080 namespaces set-retention shop/orders --time 60m --size 1024MSync
kurkik conn add pulsar a --admin-url http://pulsar-a:8080 --service-url pulsar://pulsar-a:6650 --client 4.0kurkik conn add pulsar b --admin-url http://pulsar-b:8080 --service-url pulsar://pulsar-b:6650 --client 4.0kurkik pulsar export a --this-cluster-only --acls --consumers --stdout > a.yaml # source.yaml (and b's, before: target.yaml)kurkik pulsar sync a.yaml b --overwrite --dry-run # plan-without.txtkurkik pulsar sync a.yaml b --overwrite --force --dry-run # plan.txt (and -o json: plan.json)kurkik pulsar sync a.yaml b --overwrite --force --yes # apply.txt, and the reverse patch: rollback.yamlkurkik pulsar diff a.yaml b # after.txtkurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml b --force --yes # revert.txtAll flags: kurkik pulsar sync · more Apache Pulsar sync examples
Copyright © 2026 Pavel Bodiachevskii