Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the stats of a non-persistent topic that has been cleaned causes it to re-appear #9029

Merged
merged 1 commit into from
Dec 29, 2020

Conversation

eolivelli
Copy link
Contributor

@eolivelli eolivelli commented Dec 22, 2020

If a non-persistent topic is unused it is automatically deleted by Pulsar. If you then get the stats on that topic name using the REST API, it causes that topic to re-appear.

For example, a non-persistent topic public/bob/np exists in a namespace. It is returned when using the admin/v2/non-persistent/public/bob endpoint:

["non-persistent://public/bob/np"]

Since this topic is unused, it gets cleaned and no longer is returned by the endpoint:

[]

However, if you request the stats for that topic using the CLI (which calls the REST API), like this, you actually get a response (not a 404):

bin/pulsar-admin topics stats non-persistent://public/bob/np
Warning: Nashorn engine is planned to be removed from a future JDK release
{
  "msgRateIn" : 0.0,
  "msgThroughputIn" : 0.0,
  "msgRateOut" : 0.0,
  "msgThroughputOut" : 0.0,
  "bytesInCounter" : 0,
  "msgInCounter" : 0,
  "bytesOutCounter" : 0,
  "msgOutCounter" : 0,
  "averageMsgSize" : 0.0,
  "msgChunkPublished" : false,
  "storageSize" : 0,
  "backlogSize" : 0,
  "publishers" : [ ],
  "subscriptions" : { },
  "replication" : { }
}

And now the topic re-appears on the topic-list endpoint:

["non-persistent://public/bob/np"]

Modifications

When loading a temporary topic with createIfMissing = false do not try to create it, simply return an empty value.
Add test case.

This change added tests and can be verified as in the bug description.

Run:
pulsar-admin topics create non-persistent://public/default/tmp
wait for the topic to be deleted
run
pulsar-admin topics stats non-persistent://public/default/tmp

@eolivelli
Copy link
Contributor Author

/pulsarbot run-failure-checks

@eolivelli
Copy link
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui codelipenghui added the type/bug The PR fixed a bug or issue reported a bug label Dec 23, 2020
@codelipenghui codelipenghui added this to the 2.8.0 milestone Dec 23, 2020
@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

1 similar comment
@eolivelli
Copy link
Contributor Author

/pulsarbot run-failure-checks

@sijie
Copy link
Member

sijie commented Dec 23, 2020

/pulsarbot run-failure-checks

1 similar comment
@sijie
Copy link
Member

sijie commented Dec 28, 2020

/pulsarbot run-failure-checks

@eolivelli
Copy link
Contributor Author

This patch is good to go

@sijie sijie merged commit b860c05 into apache:master Dec 29, 2020
zzzming pushed a commit to datastax/pulsar that referenced this pull request Jan 3, 2021
…ses it to re-appear (apache#9029)

If a non-persistent topic is unused it is automatically deleted by Pulsar. If you then get the stats on that topic name using the REST API, it causes that topic to re-appear.

For example, a non-persistent topic `public/bob/np` exists in a namespace. It is returned when using the `admin/v2/non-persistent/public/bob` endpoint:

```
["non-persistent://public/bob/np"]
```

Since this topic is unused, it gets cleaned and no longer is returned by the endpoint:

```
[]
```

However, if you request the stats for that topic using the CLI (which calls the REST API), like this, you actually get a response (not a 404):

```
bin/pulsar-admin topics stats non-persistent://public/bob/np
Warning: Nashorn engine is planned to be removed from a future JDK release
{
  "msgRateIn" : 0.0,
  "msgThroughputIn" : 0.0,
  "msgRateOut" : 0.0,
  "msgThroughputOut" : 0.0,
  "bytesInCounter" : 0,
  "msgInCounter" : 0,
  "bytesOutCounter" : 0,
  "msgOutCounter" : 0,
  "averageMsgSize" : 0.0,
  "msgChunkPublished" : false,
  "storageSize" : 0,
  "backlogSize" : 0,
  "publishers" : [ ],
  "subscriptions" : { },
  "replication" : { }
}
```

And now the topic re-appears on the topic-list endpoint:

```
["non-persistent://public/bob/np"]
```

When loading a temporary topic with createIfMissing = false do not try to create it, simply return an empty value.
Add test case.

This change added tests and can be verified as in the bug description.

Run:
pulsar-admin topics create non-persistent://public/default/tmp
wait for the topic to be deleted
run
pulsar-admin topics stats non-persistent://public/default/tmp
codelipenghui added a commit that referenced this pull request Jan 3, 2021
… without topic auto-creation (#9107)

### Motivation

After #9029 merged, the non-persistent topic can be created when enabling the topic auto-creation, Otherwise, the client will get a `Topic does not exist` exception. This looks like a concurrent merge related issue, but I'm not able to find another PR related to this issue.

This PR is fixing the test that wants to subscribe to a partitioned non-persistent topic but disabled the topic auto-creation. Currently, the fix is enabling the topic auto-creation for the test. For non-persistent topics, we don't persist any metadata for it in the metadata server, so for users who want to use the non-persistent topic, they must enable the topic auto-creation.
@codelipenghui codelipenghui added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Jan 7, 2021
codelipenghui pushed a commit that referenced this pull request Jan 7, 2021
…ses it to re-appear (#9029)

If a non-persistent topic is unused it is automatically deleted by Pulsar. If you then get the stats on that topic name using the REST API, it causes that topic to re-appear.

For example, a non-persistent topic `public/bob/np` exists in a namespace. It is returned when using the `admin/v2/non-persistent/public/bob` endpoint:

```
["non-persistent://public/bob/np"]
```

Since this topic is unused, it gets cleaned and no longer is returned by the endpoint:

```
[]
```

However, if you request the stats for that topic using the CLI (which calls the REST API), like this, you actually get a response (not a 404):

```
bin/pulsar-admin topics stats non-persistent://public/bob/np
Warning: Nashorn engine is planned to be removed from a future JDK release
{
  "msgRateIn" : 0.0,
  "msgThroughputIn" : 0.0,
  "msgRateOut" : 0.0,
  "msgThroughputOut" : 0.0,
  "bytesInCounter" : 0,
  "msgInCounter" : 0,
  "bytesOutCounter" : 0,
  "msgOutCounter" : 0,
  "averageMsgSize" : 0.0,
  "msgChunkPublished" : false,
  "storageSize" : 0,
  "backlogSize" : 0,
  "publishers" : [ ],
  "subscriptions" : { },
  "replication" : { }
}
```

And now the topic re-appears on the topic-list endpoint:

```
["non-persistent://public/bob/np"]
```

### Modifications
When loading a temporary topic with createIfMissing = false do not try to create it, simply return an empty value. 
Add test case.

This change added tests and can be verified as in the bug description.

Run:
pulsar-admin topics create non-persistent://public/default/tmp
wait for the topic to be deleted
run
pulsar-admin topics stats non-persistent://public/default/tmp

(cherry picked from commit b860c05)
codelipenghui added a commit that referenced this pull request Jan 7, 2021
… without topic auto-creation (#9107)

### Motivation

After #9029 merged, the non-persistent topic can be created when enabling the topic auto-creation, Otherwise, the client will get a `Topic does not exist` exception. This looks like a concurrent merge related issue, but I'm not able to find another PR related to this issue.

This PR is fixing the test that wants to subscribe to a partitioned non-persistent topic but disabled the topic auto-creation. Currently, the fix is enabling the topic auto-creation for the test. For non-persistent topics, we don't persist any metadata for it in the metadata server, so for users who want to use the non-persistent topic, they must enable the topic auto-creation.

(cherry picked from commit 21a3a3b)
@eolivelli eolivelli deleted the fix/stats-tmp-topics branch January 8, 2021 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.7 Archived: 2.7 is end of life release/2.7.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants