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

[FIXED] Allow compress after restart #6444

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

MauriceVanVeen
Copy link
Member

A replicated stream can compress the data in proposals/catchup if all servers support it. However, if a stream already exists and the servers restart then compression would not be enabled, even though all servers support it.

This was due to the compressOK flag only being set upon becoming leader, which meant that if a quorum of servers comes online and the leader is elected before the final server comes online, compression will not be enabled until there is another leader election.

We could re-calculate compressOK when a server comes online, but that could be expensive depending on the amount of servers and streams involved. Since compression has been added in v2.9.0 this means that all supported versions already support compression and there's no need to check. (Only 2.8.4 or earlier don't support it, but those are not supported versions anymore anyway and are ~3 years old at this point) So it's just simpler to clean it up and ensure compression can be used.

Signed-off-by: Maurice van Veen github@mauricevanveen.com

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
@MauriceVanVeen MauriceVanVeen requested a review from a team as a code owner February 3, 2025 10:00
@derekcollison
Copy link
Member

This mean that a 2.8.x system can not upgrade to 2.11 directly?

@MauriceVanVeen
Copy link
Member Author

This mean that a 2.8.x system can not upgrade to 2.11 directly?

Correct, would need to upgrade to 2.9.x or 2.10.x first.

@derekcollison
Copy link
Member

@kozlovic WDYT here?

@ripienaar
Copy link
Contributor

It seems acceptable to me to say we only support upgrading from 2.9 onward

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

@derekcollison derekcollison merged commit e331d07 into main Feb 3, 2025
5 checks passed
@derekcollison derekcollison deleted the maurice/compress-after-restart branch February 3, 2025 15:08
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

@kozlovic WDYT here?

I usually try to keep backward compatibility as much as possible, but it is not un-heard of having to upgrade to intermediate versions in situations like that. 2.8.x in term of version number does not look that old, but it is true that it is several years old now and hopefully users have upgraded.

My only question would be, if users don't know and go from 2.8- to latest, in a rolling upgraded, will that mess-up datastores or simply that the nodes will fail to communicate? If it is the later, it is ok, they will realize that there is an issue and hopefully can quickly realize (from release notes) that they need to do incremental update. If the former, then that's not good.

}

// Threshold for compression.
// TODO(dlc) - Eventually make configurable.
const compressThreshold = 8192 // 8k

// If allowed and contents over the threshold we will compress.
func encodeStreamMsgAllowCompress(subject, reply string, hdr, msg []byte, lseq uint64, ts int64, sourced bool, compressOK bool) []byte {
func encodeStreamMsgAllowCompress(subject, reply string, hdr, msg []byte, lseq uint64, ts int64, sourced bool) []byte {
Copy link
Member

Choose a reason for hiding this comment

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

I would have then removed this function and keep the original encodeStreamMsg(), except that encodeStreamMsg() could have the comment that says that if the content is over the threshold, it will be compressed.

Copy link
Member

Choose a reason for hiding this comment

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

I believe they will not be able to sync until all servers upgraded, should not do any data corruption.

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.

4 participants