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

Fix attach kuzu in in-mem mode #4177

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,13 @@ jobs:
run: |
python3 scripts/generate-tinysnb.py
cd scripts/ && python3 http-server.py &
make extension-test

- name: Extension test in mem
env:
IN_MEM_MODE: true
HTTP_CACHE_FILE: false
run: |
make extension-test && make clean

macos-extension-test:
Expand Down Expand Up @@ -897,7 +904,14 @@ jobs:
run: |
python3 scripts/generate-tinysnb.py
cd scripts/ && python3 http-server.py &
make extension-test && make clean
make extension-test

- name: Extension test in mem
env:
IN_MEM_MODE: true
HTTP_CACHE_FILE: false
run: |
make extension-test && make clean

windows-extension-test:
name: windows extension test
Expand Down Expand Up @@ -953,6 +967,14 @@ jobs:
if %errorlevel% neq 0 exit /b %errorlevel%
cd scripts/ && start /b python http-server.py && cd ..
make extension-test

- name: Extension test in mem
shell: cmd
env:
IN_MEM_MODE: true
HTTP_CACHE_FILE: false
run: |
make extension-test

- name: Clean
shell: cmd
Expand Down
4 changes: 3 additions & 1 deletion extension/httpfs/src/httpfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ void HTTPFileInfo::initializeClient() {

std::unique_ptr<common::FileInfo> HTTPFileSystem::openFile(const std::string& path, int flags,
main::ClientContext* context, common::FileLockType /*lock_type*/) {
initCachedFileManager(context);
if (context->getCurrentSetting(HTTPCacheFileConfig::HTTP_CACHE_FILE_OPTION).getValue<bool>()) {
initCachedFileManager(context);
}
auto httpFileInfo = std::make_unique<HTTPFileInfo>(path, this, flags, context);
httpFileInfo->initialize(context);
return httpFileInfo;
Expand Down
4 changes: 3 additions & 1 deletion extension/httpfs/src/s3fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ std::unique_ptr<common::FileInfo> S3FileSystem::openFile(const std::string& path
main::ClientContext* context, common::FileLockType /*lock_type*/) {
auto authParams = getS3AuthParams(context);
auto uploadParams = getS3UploadParams(context);
initCachedFileManager(context);
if (context->getCurrentSetting(HTTPCacheFileConfig::HTTP_CACHE_FILE_OPTION).getValue<bool>()) {
initCachedFileManager(context);
}
auto s3FileInfo =
std::make_unique<S3FileInfo>(path, this, flags, context, authParams, uploadParams);
s3FileInfo->initialize(context);
Expand Down
2 changes: 2 additions & 0 deletions extension/httpfs/test/test_files/s3_download.test
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ anotherkey
Extension exception: Extension option s3_access_key_id already exists.

-CASE ScanFromUWS3File
# In-memory mode doesn't support file cache.
-SKIP_IN_MEM
-STATEMENT load extension "${KUZU_ROOT_DIRECTORY}/extension/httpfs/build/libhttpfs.kuzu_extension"
---- ok
-STATEMENT CALL s3_access_key_id='${UW_S3_ACCESS_KEY_ID}'
Expand Down
25 changes: 20 additions & 5 deletions extension/httpfs/test/test_files/s3_remote_database.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

--

#TODO(Ziyi): figure out a way to automate upload if storage has changed.
-CASE UWS3RemoteDB
-SKIP
-DEFINE_STATEMENT_BLOCK UW_S3_SETUP [
-STATEMENT load extension "${KUZU_ROOT_DIRECTORY}/extension/httpfs/build/libhttpfs.kuzu_extension"
---- ok
-STATEMENT CALL s3_access_key_id='${UW_S3_ACCESS_KEY_ID}'
Expand All @@ -17,6 +15,12 @@
---- ok
-STATEMENT CALL s3_region='US'
---- ok
]

#TODO(Ziyi): figure out a way to automate upload if storage has changed.
-CASE UWS3RemoteDB
-SKIP
-INSERT_STATEMENT_BLOCK UW_S3_SETUP
-STATEMENT CALL HTTP_CACHE_FILE=TRUE
---- ok
-STATEMENT ATTACH 's3://kuzu-test/ldbc01' as ldbc (dbtype kuzu)
Expand All @@ -29,12 +33,23 @@ Attached database successfully.
---- 1
Detached database successfully.

-LOG AttachWithoutCache
-CASE AttachTinysnb
-INSERT_STATEMENT_BLOCK UW_S3_SETUP
-STATEMENT CALL HTTP_CACHE_FILE=FALSE
---- ok
-STATEMENT ATTACH 's3://kuzu-test/tinysnb' as ldbc (dbtype kuzu)
-STATEMENT ATTACH 's3://kuzu-test/tinysnb/tinysnb/' as ldbc (dbtype kuzu)
---- 1
Attached database successfully.
-STATEMENT match (p0:person) return p0.id
---- 8
0
2
3
5
7
8
9
10
-STATEMENT match (p0:person)-[:knows]->(p1:person) return p0.ID, p1.ID
---- 14
0|2
Expand Down
2 changes: 1 addition & 1 deletion extension/json/test/copy_to_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--

-CASE TinySnbCopyToJSON

-SKIP_IN_MEM
-STATEMENT COPY (MATCH (p:person) RETURN [id(p)], p.*) TO "${DATABASE_PATH}/tinysnb_person.json"
---- ok
-STATEMENT load from "${DATABASE_PATH}/tinysnb_person.json" return *
Expand Down
4 changes: 4 additions & 0 deletions src/main/attached_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
"path to an on-disk Kùzu database directory.");
}
auto path = vfs->expandPath(clientContext, dbPath);
// Note: S3 directory path may end with a '/'.
if (path.ends_with('/')) {
path = path.substr(0, path.size() - 1);

Check warning on line 56 in src/main/attached_database.cpp

View check run for this annotation

Codecov / codecov/patch

src/main/attached_database.cpp#L56

Added line #L56 was not covered by tests
}
initCatalog(path, clientContext);
validateEmptyWAL(path, clientContext);
storageManager = std::make_unique<storage::StorageManager>(path, true /* isReadOnly */,
Expand Down