Skip to content

[Bug] pulsar-admin set-retention reports an invalid retention policy when size != -1 #22138

@dchristle

Description

@dchristle

Search before asking

  • I searched in the issues and found nothing similar.

Version

Pulsar 3.2.0, official x86 Docker image.

Did not see this error on Pulsar 3.1.2.

Minimal reproduce step

  1. Have an existing namespace with some existing persistent topics.
  2. kubectl exec -it into a Broker pod bash shell.
  3. Run ./bin/pulsar-admin namespaces set-retention my_tenant/my_namespace -s 5T -t 2h

What did you expect to see?

The CLI should produce no output when the command completes successfully, and the retention policy returned with get-retention should reflect the desired size and time parameters.

What did you see instead?

2024-02-27T17:25:16,809+0000 [AsyncHttpClient-7-1] WARN  org.apache.pulsar.client.admin.internal.BaseResource - [http://localhost:8080/admin/v2/namespaces/my_tenant/my_namespace/retention] Failed to perform http post request: javax.ws.rs.BadRequestException: HTTP 400 {"reason":"Invalid retention policy: Setting a single time or size limit to 0 is invalid when one of the limits has a non-zero value. Use the value of -1 instead of 0 to ignore a specific limit. To disable retention both limits must be set to 0."}
Invalid retention policy: Setting a single time or size limit to 0 is invalid when one of the limits has a non-zero value. Use the value of -1 instead of 0 to ignore a specific limit. To disable retention both limits must be set to 0.

Reason: Invalid retention policy: Setting a single time or size limit to 0 is invalid when one of the limits has a non-zero value. Use the value of -1 instead of 0 to ignore a specific limit. To disable retention both limits must be set to 0.

Anything else?

We've run this command on Pulsar 3.1.2 with the same tenant/namespace & identical time and size retention parameters, and it completed successfully. Only after upgrading to 3.2.0 have we started seeing this error. Trying it other tenant/namespaces gives the same error, too.

Importantly for root-causing this, there are set-retention commands that do work.

Working:
./bin/pulsar-admin namespaces set-retention my_tenant/my_namespace -t 12h -s -1
./bin/pulsar-admin namespaces set-retention my_tenant/my_namespace -t 24h -s -1
./bin/pulsar-admin namespaces set-retention my_tenant/my_namespace -t -1 -s -1
./bin/pulsar-admin namespaces set-retention my_tenant/my_namespace -s -1 -t 12h

Not working:
./bin/pulsar-admin namespaces set-retention my_tenant/my_namespace -t -1 -s 5T
./bin/pulsar-admin namespaces set-retention my_tenant/my_namespace -s 1000G -t 12h

It looks like the command fails whenever size != -1.

I also verified with get-retention that the policy still appears to update when set-retention returns successfully, e.g. for -t 12h -s -1, get-retention returns:

{
  "retentionTimeInMinutes" : 720,
  "retentionSizeInMB" : -1
}

In case it matters, this tenant/namespace has a message_age backlog quota enabled. I tried different size/time arguments (with size != -1) relative to the respective backlog parameters and it didn't make a difference.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions