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

nsqd: topic with suffix #ephemeral does not auto-delete when there is no channel #1447

Closed
kayazinc opened this issue May 1, 2023 · 6 comments
Labels

Comments

@kayazinc
Copy link

kayazinc commented May 1, 2023

Version: 1.2.1

Based on the doc (https://nsq.io/overview/design.html)

Note, a topic/channel whose name ends in the string #ephemeral will not be buffered to disk and will instead drop messages after passing the mem-queue-size. This enables consumers which do not need message guarantees to subscribe to a channel. These ephemeral channels will also disappear after its last client disconnects. For an ephemeral topic, this implies that at least one channel has been created, consumed, and deleted (typically an ephemeral channel).

Issue:

Topic still shown / available with any channel existed.
xx0fHFd

Expected behaviour:

A topic with suffix #ephemeral will disappeared / deleted if there are no channel.

Possible duplication: #1395 (but i am using default --mem-queue-size)

@mreiferson
Copy link
Member

Can you provide nsqd logs? My guess is that the ephemeral topic was re-created (it has messages in the queue) after the last channel was deleted...

@kayazinc
Copy link
Author

kayazinc commented May 8, 2023

here is the nsqd logs, i've removed partial of the logs to exclude other stock symbols, please let me know if the logs is insufficient. Thanks.

nsqd-1  | [nsqd] 2023/05/08 06:32:04.492015 INFO: TOPIC(ESM3.quote#ephemeral): new channel(client#ephemeral)
nsqd-1  | [nsqd] 2023/05/08 06:32:04.492122 INFO: LOOKUPD(nsqlookupd:4160): channel REGISTER ESM3.quote#ephemeral client#ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833145 INFO: PROTOCOL(V2): [192.168.1.154:60689] exiting ioloop
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833227 ERROR: client(192.168.1.154:60689) - failed to read command - read tcp 172.18.0.4:4150->192.168.1.154:60689: read: connection reset by peer
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833240 INFO: PROTOCOL(V2): [192.168.1.154:60695] exiting ioloop
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833261 INFO: PROTOCOL(V2): [192.168.1.154:60691] exiting ioloop
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833259 INFO: PROTOCOL(V2): [192.168.1.154:60690] exiting ioloop
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833312 INFO: PROTOCOL(V2): [192.168.1.154:60695] exiting messagePump
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833333 ERROR: client(192.168.1.154:60690) - failed to read command - read tcp 172.18.0.4:4150->192.168.1.154:60690: read: connection reset by peer
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833292 ERROR: client(192.168.1.154:60695) - failed to read command - read tcp 172.18.0.4:4150->192.168.1.154:60695: read: connection reset by peer
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833431 INFO: PROTOCOL(V2): [192.168.1.154:60691] exiting messagePump
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833282 INFO: PROTOCOL(V2): [192.168.1.154:60692] exiting ioloop
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833467 INFO: TOPIC(order): deleting channel client#ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833453 INFO: PROTOCOL(V2): [192.168.1.154:60690] exiting messagePump
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833500 INFO: PROTOCOL(V2): [192.168.1.154:60692] exiting messagePump
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833494 INFO: PROTOCOL(V2): [192.168.1.154:60689] exiting messagePump
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833268 INFO: PROTOCOL(V2): [192.168.1.154:60688] exiting ioloop
nsqd-1  | [nsqd] 2023/05/08 06:32:24.833271 INFO: PROTOCOL(V2): [192.168.1.154:60700] exiting ioloop
nsqd-1  | [nsqd] 2023/05/08 06:32:24.834003 INFO: TOPIC(ESM3.quote#ephemeral): deleting
nsqd-1  | [nsqd] 2023/05/08 06:32:24.834637 INFO: TOPIC(ESM3.quote#ephemeral): closing ... messagePump
nsqd-1  | [nsqd] 2023/05/08 06:32:24.835754 INFO: LOOKUPD(nsqlookupd:4160): channel UNREGISTER ESM3.quote#ephemeral client#ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:24.836167 INFO: LOOKUPD(nsqlookupd:4160): channel UNREGISTER order client#ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:24.836698 INFO: LOOKUPD(nsqlookupd:4160): topic UNREGISTER ESM3.quote#ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:29.747131 INFO: TOPIC(ESM3.quote#ephemeral): created
nsqd-1  | [nsqd] 2023/05/08 06:32:29.747178 INFO: CI: querying nsqlookupd http://efb3539eef82:4161/channels?topic=ESM3.quote%23ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:29.747274 INFO: LOOKUPD(nsqlookupd:4160): topic REGISTER ESM3.quote#ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:42.102604 INFO: 200 GET /stats?format=json (172.18.0.3:51134) 381.877µs

@mreiferson
Copy link
Member

mreiferson commented May 30, 2023

nsqd-1  | [nsqd] 2023/05/08 06:32:24.834003 INFO: TOPIC(ESM3.quote#ephemeral): deleting
nsqd-1  | [nsqd] 2023/05/08 06:32:24.834637 INFO: TOPIC(ESM3.quote#ephemeral): closing ... messagePump
nsqd-1  | [nsqd] 2023/05/08 06:32:24.835754 INFO: LOOKUPD(nsqlookupd:4160): channel UNREGISTER ESM3.quote#ephemeral client#ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:24.836167 INFO: LOOKUPD(nsqlookupd:4160): channel UNREGISTER order client#ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:24.836698 INFO: LOOKUPD(nsqlookupd:4160): topic UNREGISTER ESM3.quote#ephemeral
nsqd-1  | [nsqd] 2023/05/08 06:32:29.747131 INFO: TOPIC(ESM3.quote#ephemeral): created

You can see here that the last client disconnects and the topic EMS3.quote#ephemeral is deleted, then ~ 5s later the topic is recreated, presumably due to a message being published to that topic...

@mreiferson mreiferson closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2023
@kayazinc
Copy link
Author

kayazinc commented May 30, 2023

You can see here that the last client disconnects and the topic EMS3.quote#ephemeral is deleted, then ~ 5s later the topic is recreated, presumably due to a message being published to that topic...

Yes, my quote engine is designed to publish message to the ephemeral topic, regardless whether there is any channel connected.

Most likely i have misundersood the characteristic of ephemeral topic. So in order to prevent the ephemeral topic from "appearing" i.e. storing messages when there is no channel connected, i need to set mem-queue-size to 0? And mem-queue-size is a global var used by all topics regardless of ephemeral or not?

Need help and more clarifications from you @mreiferson. Thanks!

@mreiferson
Copy link
Member

A (new) ephemeral topic that has no channels (and thus no clients consuming), e.g. one that was created as a result of publishing a message, will not get cleaned up until a client connects (creating a channel, presumably ephemeral) and then disconnects (triggering the ephemeral channel cleanup and then the ephemeral topic cleanup).

@kayazinc
Copy link
Author

kayazinc commented May 30, 2023

I think my requirement is similar to #567, thank you for the clarification @mreiferson. 👍

Ability to set a max queue size per-topic, especially for ephemeral topics that have no channels/consumers.
An even better situation would be for ephemeral topics to not queue messages at all when there are no channels/consumers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants