Skip to content

Comments

Generate ETags for InMemory and LocalFileSystem (#4879)#4922

Merged
tustvold merged 4 commits intoapache:masterfrom
tustvold:support-etag-in-memory
Oct 17, 2023
Merged

Generate ETags for InMemory and LocalFileSystem (#4879)#4922
tustvold merged 4 commits intoapache:masterfrom
tustvold:support-etag-in-memory

Conversation

@tustvold
Copy link
Contributor

Which issue does this PR close?

Part of apache/arrow-rs-object-store#129

Rationale for this change

Implements ETag for InMemory using a simple monotonic counter.

What changes are included in this PR?

Are there any user-facing changes?

@tustvold tustvold changed the title Support ETag in InMemory (#4879) Support ETag in InMemory and LocalFileSystem (#4879) Oct 11, 2023

#[cfg(not(unix))]
fn get_inode(metadata: &Metadata) -> u64 {
0
Copy link
Contributor Author

@tustvold tustvold Oct 11, 2023

Choose a reason for hiding this comment

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

The inode isn't strictly necessary, it is still a pretty strong ETag without it, but on Unix systems we might as well make use of it.

A happy consequence of the way most operations create a new file and then link it into place, is that the inode is actually a pretty good change detector

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this comment. If the inode isn't needed, then what value does including it add?

Either modification time and size (along with path) uniquely determines the result, or it isn't...

Perhaps the inode can detect file modifications that do not change the modification timestamp (some sort of symlink shenanigans, perhaps 🤔 )

Copy link
Contributor

Choose a reason for hiding this comment

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

In any event I think this "inode is not necessary" context should be encoded as comments in the source code

Copy link
Contributor

Choose a reason for hiding this comment

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

I see you have clarified the comment that inode is used to be more resistent to collisions -- sounds good to me

Copy link
Contributor

@crepererum crepererum left a comment

Choose a reason for hiding this comment

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

Minor naming nitpick.

source: format!("{} >= {}", date, last_modified).into(),
///
/// <https://datatracker.ietf.org/doc/html/rfc7232#section-6>
fn test(&self, meta: &ObjectMeta) -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn test(&self, meta: &ObjectMeta) -> Result<()> {
fn check_modification_conditions(&self, meta: &ObjectMeta) -> Result<()> {

"test" is rather non-descriptive and is easily confused w/ unit tests.

@alamb alamb changed the title Support ETag in InMemory and LocalFileSystem (#4879) Generate ETags for InMemory and LocalFileSystem (#4879) Oct 16, 2023
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @tustvold -- the Etag feature is getting quite cool and complete.

I had two major comments:

etag test coverage

It seems like there is no test coverage of the etag generation functionality or did I miss that? When I say "no coverage" I mean we could remove all this code and all the tests would keep passing

etag documentation

Also, it seems like etags in general are not well documented in the object_store crate: https://docs.rs/object_store/latest/object_store/?search=etag

I suggest that we add documentation:

  1. etags are a supported feature of the crate (perhaps a Etag section with brief introduction and example of how to use them, along with which object store adapters support them)
  2. Improve https://docs.rs/object_store/latest/object_store/struct.ObjectMeta.html#structfield.e_tag to refer back to the example, and pointing at check_preconditions)?

I think the tests should be done prior to merge. The documentation is not strictly necessary


#[cfg(not(unix))]
fn get_inode(metadata: &Metadata) -> u64 {
0
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this comment. If the inode isn't needed, then what value does including it add?

Either modification time and size (along with path) uniquely determines the result, or it isn't...

Perhaps the inode can detect file modifications that do not change the modification timestamp (some sort of symlink shenanigans, perhaps 🤔 )


#[cfg(not(unix))]
fn get_inode(metadata: &Metadata) -> u64 {
0
Copy link
Contributor

Choose a reason for hiding this comment

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

In any event I think this "inode is not necessary" context should be encoded as comments in the source code

storage: SharedStorage,
}

type Entry = (Bytes, DateTime<Utc>, usize);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should document what this triple is (specifically that the usize is an Etag)

let last_modified = meta.last_modified;

if let Some(m) = &self.if_match {
if m != "*" && m.split(',').map(str::trim).all(|x| x != etag) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add an explicit mention of * handling as well as support for the , handling to the docstrings (so someone can see it on docs.rs)?

// DELETE nonexisting location
// PUT overwriting
#[test]
fn test_get_options() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really a test of check_preconditions isn't it?

Suggested change
fn test_get_options() {
fn test_pre_conditions() {

Copy link
Contributor Author

@tustvold tustvold Oct 16, 2023

Choose a reason for hiding this comment

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

I opted to make these tests "mandatory" as now all stores should support them

@tustvold tustvold force-pushed the support-etag-in-memory branch from 9d0a02d to 8aad50d Compare October 16, 2023 20:05
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @tustvold -- looks great to me


#[cfg(not(unix))]
fn get_inode(metadata: &Metadata) -> u64 {
0
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you have clarified the comment that inode is used to be more resistent to collisions -- sounds good to me

@tustvold tustvold merged commit ab87abd into apache:master Oct 17, 2023
alamb pushed a commit to alamb/arrow-rs that referenced this pull request Mar 20, 2025
…#4922)

* Support ETag in InMemory (#4879)

* Add LocalFileSystem Etag

* Review feedback

* Review feedback
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.

3 participants