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

pkg/ccl/storageccl/engineccl: ensure encryption percentage does not e… #103783

Merged

Conversation

raggar
Copy link
Contributor

@raggar raggar commented May 23, 2023

ensure encryption percentage does not exceed 100%

package: pkg/ccl/storageccl/engineccl

Previously, the TotalFiles property from GenEnvStats() returned the
total number of files known to Pebble, however this results in encryption
percentages that are greater than 100%. The fix is to set TotalFiles to
be the maximum of the files known to Pebble and the files known by the
file registry. This applies to the TotalBytes property as well.

Fixes: #97874

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@raggar raggar force-pushed the rahulaggarwal_encryption_file_count branch from 00c16da to b6241af Compare May 23, 2023 15:09
@raggar raggar closed this May 23, 2023
@raggar raggar deleted the rahulaggarwal_encryption_file_count branch May 23, 2023 15:15
@raggar raggar restored the rahulaggarwal_encryption_file_count branch May 23, 2023 15:16
@raggar raggar reopened this May 23, 2023
@raggar raggar force-pushed the rahulaggarwal_encryption_file_count branch 5 times, most recently from f69c191 to 431a100 Compare May 23, 2023 17:19
@raggar raggar marked this pull request as ready for review May 23, 2023 17:19
@raggar raggar requested a review from a team as a code owner May 23, 2023 17:19
@raggar raggar requested review from itsbilal and jbowens May 23, 2023 17:19
package: pkg/ccl/storageccl/engineccl

Previously, the TotalFiles property from GenEnvStats() returned the
total number of files known to Pebble, however this results in encryption
percentages that are greater than 100%. The fix is to set TotalFiles to
be the maximum of the files known to Pebble and the files known by the
file registry. This applies to the TotalBytes property as well.

Fixes: cockroachdb#97874

Release note: None
@raggar raggar force-pushed the rahulaggarwal_encryption_file_count branch from 431a100 to 3fa3d2d Compare May 23, 2023 17:30
@RaduBerinde
Copy link
Member

pkg/storage/pebble.go line 1877 at r1 (raw file):

	// Ensure that encryption percentage does not exceed 100%.
	frFileLen := uint64(len(fr.Files))
	if stats.TotalFiles < frFileLen {

Don't we want to cap it to ActiveFiles?

@RaduBerinde
Copy link
Member

pkg/storage/pebble.go line 1877 at r1 (raw file):

Previously, RaduBerinde wrote…

Don't we want to cap it to ActiveFiles?

Feels like if there are files unaccounted by Pebble, we would show something under 100% in the steady-state

Copy link
Collaborator

@jbowens jbowens left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @itsbilal and @RaduBerinde)


pkg/storage/pebble.go line 1877 at r1 (raw file):

Previously, RaduBerinde wrote…

Feels like if there are files unaccounted by Pebble, we would show something under 100% in the steady-state

Since there's a bit of subtlety here, maybe we should add a comment:

len(fr.Files) is the total number of files known to the file registry. This includes all files created by Cockroach since encryption-at-rest was first enabled. If encryption-at-rest is subsequently disabled, new files will still be encoded within the registry. If encryption-at-rest has always been enabled, this count is as complete as you can get.

The existing stats.TotalFiles (computed up above from Pebble Metrics), holds an approximation of all the files known to Pebble. This does not include files that are being asynchronously deleted by Pebble, files that are stored in the auxiliary directory (typically sstables being prepared for ingestion by sideloading), or files created by spilling-to-disk.

If we knew encryption-at-rest had always been enabled, len(fr.Files) would be the true number of files. Since we don't know that, we use Pebble's count of files as a lower bound.

@raggar
Copy link
Contributor Author

raggar commented May 24, 2023

bors r+

@craig
Copy link
Contributor

craig bot commented May 24, 2023

This PR was included in a batch that timed out, it will be automatically retried

@craig
Copy link
Contributor

craig bot commented May 24, 2023

Build succeeded:

@craig craig bot merged commit aaaae95 into cockroachdb:master May 24, 2023
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.

storage: encryption stats show >100% files encrypted with active key
4 participants