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

NSFS | versioning | calculate multipart upload version by creation time #8644

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nadavMiz
Copy link
Contributor

@nadavMiz nadavMiz commented Jan 2, 2025

Explain the changes

according to aws specifications multipart upload version creation time rather than completion time. this effects version ordering as will no have the latest version if another object was uploaded after multipart upload creation but before completion

  1. add fs_napi function utimensat to change access time of files. see https://man7.org/linux/man-pages/man3/futimens.3p.html
  2. change the mtime of the upload file after mp completion to have the creation time, for correct version id time
  3. on move_to_dest_versioning add case: when the version is not latest move directly to .version and break since we don't need to handle latest version (it remains the same in this case)
  4. add tests for both new fs function and multipart upload order

Issues: Fixed #8411

Testing Instructions:

  1. utimensat fs function - sudo node ./node_modules/mocha/bin/mocha src/test/unit_tests/test_nb_native_fs.js
  2. multipart upload versioning - sudo NC_CORETEST=true node ./node_modules/mocha/bin/mocha src/test/unit_tests/test_bucketspace_versioning.js
  • Doc added/updated
  • Tests added

@nadavMiz nadavMiz requested review from guymguym and romayalon January 2, 2025 09:31
@nadavMiz nadavMiz force-pushed the multipart-version-ordering branch 6 times, most recently from 12445b6 to 2c10bc0 Compare January 5, 2025 05:25
@nadavMiz nadavMiz self-assigned this Jan 8, 2025
@nadavMiz nadavMiz force-pushed the multipart-version-ordering branch from 2c10bc0 to b3b9a42 Compare January 8, 2025 12:29
src/native/fs/fs_napi.cpp Show resolved Hide resolved
src/native/fs/fs_napi.cpp Show resolved Hide resolved
src/test/unit_tests/test_nb_native_fs.js Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/test/unit_tests/test_bucketspace_versioning.js Outdated Show resolved Hide resolved
src/test/unit_tests/test_bucketspace_versioning.js Outdated Show resolved Hide resolved
@shirady
Copy link
Contributor

shirady commented Jan 13, 2025

@nadavMiz I'm adding a TODO here so we will not forget - run the test on MAC as well.

@nadavMiz nadavMiz force-pushed the multipart-version-ordering branch 2 times, most recently from cc844df to 7d5bf69 Compare January 14, 2025 09:33
src/sdk/namespace_fs.js Show resolved Hide resolved
const create_object_upload_stat = await nb_native().fs.stat(fs_context, create_object_upload_path);
//according to aws, multipart upload version time should be calculated based on creation rather then completion time.
//change the files mtime to match the creation time
await nb_native().fs.utimensat(fs_context, upload_path, {modtime: create_object_upload_stat.mtimeNsBigint});
Copy link
Contributor

Choose a reason for hiding this comment

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

do you think we should fail the whole upload in case we were not able to set the mtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we can use the existing time in case it fails

Copy link
Contributor

Choose a reason for hiding this comment

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

@guymguym WDYT? I'm not sure, since it might create a wrong .versions/ stack order, but on the other hand we probably don't want to fail on that

src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Show resolved Hide resolved
src/sdk/nb.d.ts Outdated Show resolved Hide resolved
SYSCALL_OR_RETURN(utimensat(AT_FDCWD, _path.c_str(), _times, 0));
}

void get_time_from_info(const Napi::Object& napi_times, const std::string& time_type, struct timespec& timeval, std::string& log_str) {
Copy link
Contributor

Choose a reason for hiding this comment

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

pls move helper functions to not be in the middle of the workers

Copy link
Contributor Author

@nadavMiz nadavMiz Jan 14, 2025

Choose a reason for hiding this comment

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

get_time_from_info is only relevant to utimensat, so I added it as a member function to the class. where would you propose to move it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw helper functions both at the top and at the bottom of this file, so check what you think is the best location

src/native/fs/fs_napi.cpp Show resolved Hide resolved
src/native/fs/fs_napi.cpp Show resolved Hide resolved
@nadavMiz nadavMiz force-pushed the multipart-version-ordering branch 2 times, most recently from 8c7187b to 5bcf21d Compare January 19, 2025 11:10
@nadavMiz nadavMiz force-pushed the multipart-version-ordering branch from 5bcf21d to ba6cf8c Compare January 19, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants