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

Database access mode #2089

Merged
merged 1 commit into from
Oct 17, 2023
Merged

Database access mode #2089

merged 1 commit into from
Oct 17, 2023

Conversation

hououou
Copy link
Collaborator

@hououou hououou commented Sep 26, 2023

This PR is aimed at solving issue #921 on non-Windows platforms.

Steps:

  • Add a file .lock in each database directory. Use this file to check the status of the database.
  • When a database is started with an access mode referring to as READ_ONLY or READ_WRITE (note I use READ_WRITE when the access mode is not specified), lock the .lock using the function fcntl.

Limitation

  • fcntl can only solve the read-write lock during different processes. So we cannot solve the read-write lock in the same process.

Copy link
Contributor

@ray6080 ray6080 left a comment

Choose a reason for hiding this comment

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

Did a pre-review while this is still a draft. please check my comments.
There are still some code not cleaned up. Let me know when it is ready for another review.

examples/cpp/CMakeLists.txt Outdated Show resolved Hide resolved
examples/cpp/main.cpp Outdated Show resolved Hide resolved
src/common/file_utils.cpp Show resolved Hide resolved
@@ -15,6 +15,24 @@
namespace kuzu {
namespace common {

enum class FileLockType : uint8_t { NO_LOCK = 0, READ_LOCK = 1, WRITE_LOCK = 2 };

class FileFlags {
Copy link
Contributor

Choose a reason for hiding this comment

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

This class should be cleaned after you merge locking logic into existing openFile function.

src/main/database.cpp Outdated Show resolved Hide resolved
src/include/main/database.h Outdated Show resolved Hide resolved
test/runner/test_locking.cpp Outdated Show resolved Hide resolved
@hououou hououou force-pushed the access_mode branch 2 times, most recently from 6ba2181 to 70223a4 Compare September 27, 2023 16:06
@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (1a3b814) 89.55% compared to head (392d4a9) 89.58%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2089      +/-   ##
==========================================
+ Coverage   89.55%   89.58%   +0.02%     
==========================================
  Files        1007     1006       -1     
  Lines       36250    36273      +23     
==========================================
+ Hits        32465    32496      +31     
+ Misses       3785     3777       -8     
Files Coverage Δ
src/common/file_utils.cpp 78.65% <100.00%> (+1.27%) ⬆️
src/include/common/file_utils.h 100.00% <ø> (ø)
src/include/main/connection.h 100.00% <ø> (ø)
src/include/storage/storage_utils.h 100.00% <100.00%> (ø)
src/main/connection.cpp 90.56% <100.00%> (+0.43%) ⬆️
src/main/database.cpp 100.00% <100.00%> (ø)

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/include/main/database.h Outdated Show resolved Hide resolved
@hououou hououou marked this pull request as ready for review September 28, 2023 08:47
Copy link
Contributor

@ray6080 ray6080 left a comment

Choose a reason for hiding this comment

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

Didn't look into tests yet. Will continue later.

src/common/file_utils.cpp Outdated Show resolved Hide resolved
src/common/file_utils.cpp Outdated Show resolved Hide resolved
src/include/main/database.h Outdated Show resolved Hide resolved
src/include/main/database.h Outdated Show resolved Hide resolved
src/main/connection.cpp Outdated Show resolved Hide resolved
src/main/database.cpp Outdated Show resolved Hide resolved
src/main/database.cpp Outdated Show resolved Hide resolved
src/main/database.cpp Outdated Show resolved Hide resolved
src/main/database.cpp Outdated Show resolved Hide resolved
src/include/main/database.h Outdated Show resolved Hide resolved
Copy link
Contributor

@ray6080 ray6080 left a comment

Choose a reason for hiding this comment

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

Didn't look into tests yet. Will continue later when you finalize changes to tests.

@ray6080 ray6080 changed the title Acces mode (first version) Database access mode Sep 30, 2023
@acquamarin acquamarin force-pushed the access_mode branch 2 times, most recently from 3d30627 to 3660a9c Compare October 16, 2023 17:39
@acquamarin acquamarin merged commit 2da282a into master Oct 17, 2023
11 checks passed
@acquamarin acquamarin deleted the access_mode branch October 17, 2023 12:32
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.

None yet

3 participants