Skip to content

GH-40731: [C++][Parquet] Minor enhancement code of encryption - #40732

Merged
pitrou merged 2 commits into
apache:mainfrom
mapleFU:minor-enhancement
Mar 26, 2024
Merged

pitrou merged 2 commits into
apache:mainfrom
mapleFU:minor-enhancement

Conversation

@mapleFU

@mapleFU mapleFU commented Mar 22, 2024 •

Copy link
Copy Markdown
Member

Rationale for this change

  • Applying more std::move in encryption
  • Trying to use NULLPTR rather than NULL.

What changes are included in this PR?

Applying more std::move in encryption

Are these changes tested?

No need

Are there any user-facing changes?

No

@mapleFU
mapleFU requested a review from wgtmac as a code owner March 22, 2024 03:26
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #40731 has been automatically assigned in GitHub to PR creator.

std::shared_ptr<FileKeyMaterialStore> key_material_store)
: FileKeyUnwrapper(/*key_toolkit_owner=*/nullptr, key_toolkit, kms_connection_config,
cache_lifetime_seconds, /*file_path=*/"",
cache_lifetime_seconds, std::move(key_material_store),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@adamreeve I found previously this key_material_store is not used. Is this expected?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that FileKeyMaterialStore is only required when master key rotation is used. Otherwise it is null and created internally based on file path and file system.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be good for @adamreeve to double check if this is required. If not, we probably should remove the parameter to reduce confusion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is unexpected. It looks like during the process of working on #34181 I refactored things so that this parameter was no longer used but didn't realise this. The FileKeyUnwrapper created in KeyToolkit::RotateMasterKeys is only ever used to call GetDataEncryptionKey, which takes a KeyMaterial parameter so bypasses the key_material_store_ completely, and there's no reason it should need to be passed in to the constructor.

I also added an incorrect comment about this constructor overload in file_key_unwrapper.h, saying, "This is useful for key rotation to allow accessing the key material store after it is used." I guess I got myself confused with the use of the temp_key_material_store passed to the FileKeyWrapper.

It seems to me that this overload can be removed completely, and KeyToolkit::RotateMasterKeys can use the other constructor. The file_path and filesystem could be provided but won't be used.

@adamreeve adamreeve Mar 22, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh actually it looks like the constructor parameter was being used prior to #40329, I didn't notice an extra commit was added to that PR to refactor the constructor parameters making it no longer used (7547c79). But even though it was being used to set key_material_store_ before, that was never actually required for KeyToolkit::RotateMasterKeys and the extra constructor overload wasn't needed.

@mapleFU mapleFU Mar 22, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So my edit is correct? Or I should removing this? I'm not sure would legacy user using this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah I think it depends on whether removing the overload is likely to affect any users. Your change is correct, but @pitrou's change not breaking anything exposed that the extra overload wasn't really needed by KeyToolkit::RotateMasterKeys. I guess it doesn't hurt to keep it as is, but it might be nice to remove the overload to simplify things.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with the current change to fix the missing argument instead of removing a public function.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you open an issue for exploring whether the overload can be removed? In the meantime we can merge this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure

@mapleFU

mapleFU commented Mar 22, 2024

Copy link
Copy Markdown
Member Author

Also cc @pitrou

@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 145c4d3.

There was 1 benchmark result with an error:

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 26 possible false positives for unstable benchmarks that are known to sometimes produce them.

pitrou pushed a commit that referenced this pull request Mar 27, 2024
#40808)

### Rationale for this change

I added this comment in #34181, but from the discussion in #40732 (comment), I realised this comment was incorrect. The extra overload appears to just be a convenience as a `FileKeyMaterialStore` is already constructed in `KeyToolkit::RotateMasterKeys`, but the store isn't actually used by the `FileKeyUnwrapper` in that method, as only `FileKeyUnwrapper::GetDataEncryptionKey` is called, which bypasses the store.

`RotateMasterKeys` does however rely on the `temp_key_material_store` passed to the `FileKeyWrapper` being used, which is possibly where this confusion came from.

### What changes are included in this PR?

Removes an incorrect statement from a C++ header comment.

### Are these changes tested?

NA

### Are there any user-facing changes?

No

Authored-by: Adam Reeve <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
vibhatha pushed a commit to vibhatha/arrow that referenced this pull request May 25, 2024
apache#40808)

### Rationale for this change

I added this comment in apache#34181, but from the discussion in apache#40732 (comment), I realised this comment was incorrect. The extra overload appears to just be a convenience as a `FileKeyMaterialStore` is already constructed in `KeyToolkit::RotateMasterKeys`, but the store isn't actually used by the `FileKeyUnwrapper` in that method, as only `FileKeyUnwrapper::GetDataEncryptionKey` is called, which bypasses the store.

`RotateMasterKeys` does however rely on the `temp_key_material_store` passed to the `FileKeyWrapper` being used, which is possibly where this confusion came from.

### What changes are included in this PR?

Removes an incorrect statement from a C++ header comment.

### Are these changes tested?

NA

### Are there any user-facing changes?

No

Authored-by: Adam Reeve <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants