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

[IMPROVED] MQTT stream per session replaced with single stream #2501

Merged
merged 2 commits into from
Sep 9, 2021

Conversation

kozlovic
Copy link
Member

@kozlovic kozlovic commented Sep 8, 2021

With the availability of a "max message per subject" for a given
stream, it is possible to replace individual streams that were
created per session with a single stream that gets all sessions
as a single message per subject, which subject is composed of
the session client ID hash.

The first time the new stream is created for a given account,
all existing MQTT session streams will be transferred to the
new mux'ed MQTT session stream.

Signed-off-by: Ivan Kozlovic ivan@synadia.com

With the availability of a "max message per subject" for a given
stream, it is possible to replace individual streams that were
created per session with a single stream that gets all sessions
as a single message per subject, which subject is composed of
the session client ID hash.

The first time the new stream is created for a given account,
all existing MQTT session streams will be transferred to the
new mux'ed MQTT session stream.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
@@ -200,6 +201,7 @@ func (c *cluster) shutdown() {
os.Remove(cf)
}
if sd != _EMPTY_ {
sd = strings.TrimSuffix(sd, JetStreamStoreDir)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derekcollison I noticed that the temporary directory nats-server would still be filled with empty directory, such as jetstream12345678. Since it seems that under this directory, the server would actually create jetstream directory, this remove all would remove jetstream but leave the empty parent directory.
This change helps cleaning up, and seems that JetStream pass, but keep that in mind if later when writing a test in case this change has an effect (for instance if you were expecting only jetstream to be removed but not the parent dir, etc..).

server/mqtt.go Show resolved Hide resolved
server/mqtt.go Show resolved Hide resolved
server/mqtt.go Show resolved Hide resolved
server/mqtt.go Outdated Show resolved Hide resolved
server/mqtt.go Outdated Show resolved Hide resolved
server/mqtt.go Show resolved Hide resolved
server/mqtt.go Show resolved Hide resolved
server/mqtt.go Show resolved Hide resolved
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kozlovic kozlovic merged commit 9e5526c into main Sep 9, 2021
@kozlovic kozlovic deleted the mqtt_sess_changes branch September 9, 2021 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants