Skip to content

fix gcs compile error.#75

Merged
thweetkomputer merged 2 commits intomainfrom
fix-gcs-compile
Nov 4, 2025
Merged

fix gcs compile error.#75
thweetkomputer merged 2 commits intomainfrom
fix-gcs-compile

Conversation

@thweetkomputer
Copy link
Collaborator

@thweetkomputer thweetkomputer commented Sep 12, 2025

Summary by CodeRabbit

  • Refactor
    • Cloud storage backend compilation is now conditional so S3-specific components are included only when S3 support is enabled.
    • AWS initialization, credential checks, and shutdown are confined to the S3-enabled path; GCP storage behavior remains unchanged.
    • Reduces unnecessary cloud-specific code in builds that do not enable S3.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Adds preprocessor guards around S3-specific code, moving S3 client factory, AWS includes, Init/Shutdown, credential checks, and endpoint wiring behind DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3; introduces explicit #elif for GCP filesystem selection and adjusts some variable scopes for guarded use.

Changes

Cohort / File(s) Summary
Header Declaration Guards
eloq_data_store_service/rocksdb_cloud_data_store.h
BuildS3ClientFactory(const std::string &endpoint) declaration wrapped with #if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3) / #endif
S3 Implementation Guards
eloq_data_store_service/rocksdb_cloud_data_store.cpp
BuildS3ClientFactory definition and all S3-related credential, endpoint and client-factory code wrapped with #if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3); rocksdb::Status status; declaration moved outside guard and subsequent assignments placed inside guarded regions
Cloud Dump & Provider Selection
eloq_data_store_service/rocksdb_cloud_dump.cpp
AWS SDK includes and Aws::InitAPI/Aws::ShutdownAPI calls guarded by S3 macro; added guarded buildS3ClientFactory function; cloud filesystem creation and credential validation split into #if (AWS/S3) / #elif (GCP) branches; AWS cleanup moved behind matching guards on all exit paths

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant CLI as CLI/main
    participant Core as rocksdb_cloud_dump
    participant FS as CloudFS
    participant DB as RocksDB

    CLI->>Core: start
    Core->>Core: prepare cfs_options
    alt DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3 defined
        Core->>Core: Aws::InitAPI()
        Core->>Core: buildS3ClientFactory(endpoint)
        Core->>FS: NewAwsFileSystem(cfs_options, s3_factory)
    else GCP path
        Core->>FS: NewGcpFileSystem(cfs_options)
    end
    FS->>Core: filesystem ready
    Core->>DB: Open DB with filesystem
    alt success
        DB->>Core: opened
    else failure
        DB->>Core: error
    end
    alt S3 initialized
        Core->>Core: Aws::ShutdownAPI()
    end
    Core->>CLI: exit
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to guarded initialization vs shutdown symmetry in rocksdb_cloud_dump.cpp
  • Verify status and cloudfs option variable scopes in rocksdb_cloud_data_store.cpp after moving declarations
  • Confirm header/public API visibility change for BuildS3ClientFactory is intentional and consistent with build configurations

Poem

🐰 I hopped through #ifs, with endpoints in paw,

S3 tucked away, GCP left the door,
Guards set in place, builds choose their sky,
A little rabbit cheer — compile and fly! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title claims to fix a 'gcs compile error', but the changes exclusively add conditional compilation guards for S3 (DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3), not GCS. The actual changes relate to S3 support, not GCS. Correct the title to accurately reflect that the changes address S3 conditional compilation, e.g., 'Add S3 conditional compilation guards' or 'Make S3 support optional via compile flags'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-gcs-compile

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 87def1e and 213b3b7.

📒 Files selected for processing (3)
  • eloq_data_store_service/rocksdb_cloud_data_store.cpp (6 hunks)
  • eloq_data_store_service/rocksdb_cloud_data_store.h (1 hunks)
  • eloq_data_store_service/rocksdb_cloud_dump.cpp (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • eloq_data_store_service/rocksdb_cloud_data_store.h
  • eloq_data_store_service/rocksdb_cloud_data_store.cpp
🔇 Additional comments (5)
eloq_data_store_service/rocksdb_cloud_dump.cpp (5)

23-26: LGTM!

The preprocessor guard correctly isolates AWS-specific includes, preventing compilation errors when building for GCP.


408-415: LGTM!

The S3 endpoint configuration is correctly guarded and will only execute when building for S3.


475-477: LGTM!

AWS shutdown is correctly guarded for the list_cf early exit path.


530-532: LGTM!

AWS shutdown is correctly guarded for the opendb early exit path.


642-644: LGTM!

AWS shutdown is correctly guarded for the main cleanup path.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
eloq_data_store_service/rocksdb_cloud_dump.cpp (4)

23-24: Guard AWS headers with conditional compilation.

AWS SDK headers are included unconditionally but are only needed when DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3 is defined. This creates unnecessary dependencies when building for GCP.

Apply this diff to conditionally include AWS headers:

+#if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3)
 #include <aws/core/Aws.h>
 #include <aws/s3/S3Client.h>
+#endif
 #include <gflags/gflags.h>

142-157: Guard AWS credential validation with conditional compilation.

The validation of AWS credentials (lines 142-149) is executed regardless of the backend. When building for GCP, these AWS-specific checks should not be required.

Apply this diff to conditionally validate AWS credentials:

+#if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3)
     // Validate required parameters
     if (params.aws_access_key_id.empty())
     {
         throw std::runtime_error("AWS access key ID is required");
     }
     if (params.aws_secret_key.empty())
     {
         throw std::runtime_error("AWS secret access key is required");
     }
+#endif
     if (params.bucket_name.empty())
     {

349-376: Critical: Move variable declarations outside the conditional block.

Variables aws_options (line 351), cfs_options (line 355), and status (line 369) are declared inside the DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3 guard but are used outside this block:

  • cfs_options is used at lines 378-408
  • aws_options is used at lines 468, 521, and 631
  • status is used at lines 413, 416, and 420

When DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_GCP is defined without DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3, these variables will be undeclared, causing compilation failures. The AI summary mentions that the related file rocksdb_cloud_data_store.cpp moves the status initialization outside the ifdef block, but this pattern is not applied here.

Apply this diff to declare variables before the conditional block:

         // Create directory for DB path if it doesn't exist
         std::filesystem::create_directories(params.db_path);
 
+        // Declare variables used across multiple backends
+        rocksdb::Status status;
+        rocksdb::CloudFileSystemOptions cfs_options;
+#if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3)
+        Aws::SDKOptions aws_options;
+#endif
+
 #if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3)
         // Initialize AWS SDK
-        Aws::SDKOptions aws_options;
         Aws::InitAPI(aws_options);
 
-        // Set up cloud filesystem options
-        rocksdb::CloudFileSystemOptions cfs_options;
-
         // Set credentials
         if (!params.aws_access_key_id.empty() && !params.aws_secret_key.empty())
         {
             cfs_options.credentials.InitializeSimple(params.aws_access_key_id,
                                                      params.aws_secret_key);
         }
         else
         {
             cfs_options.credentials.type = rocksdb::AwsAccessType::kUndefined;
         }
 
         // Validate credentials
-        rocksdb::Status status = cfs_options.credentials.HasValid();
+        status = cfs_options.credentials.HasValid();
         if (!status.ok())
         {
             LOG(ERROR) << "Invalid AWS credentials: " << status.ToString();

468-468: Guard AWS SDK shutdown with conditional compilation.

Aws::ShutdownAPI(aws_options) is called unconditionally, but aws_options is only declared when DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3 is defined. Additionally, lines 521 and 631 have the same issue.

Apply this diff at lines 468, 521, and 631:

             cloud_env = nullptr;
             cloud_fs = nullptr;
+#if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3)
             Aws::ShutdownAPI(aws_options);
+#endif
             google::ShutdownGoogleLogging();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5fa954e and 971473b.

📒 Files selected for processing (1)
  • eloq_data_store_service/rocksdb_cloud_dump.cpp (3 hunks)

@thweetkomputer thweetkomputer changed the title fix compile error. fix gcs compile error. Oct 29, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
eloq_data_store_service/rocksdb_cloud_data_store.cpp (2)

22-23: Guard AWS SDK includes with preprocessor directive.

These AWS SDK headers are only used in the S3-specific BuildS3ClientFactory method (now guarded at lines 205-266). When building without S3 support, these headers won't be available and will cause compilation errors.

Apply this diff to guard the includes:

+#if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3)
 #include <aws/core/client/ClientConfiguration.h>
 #include <aws/s3/S3Client.h>
+#endif
 #include <bthread/condition_variable.h>

205-266: Guard AWS SDK includes in rocksdb_cloud_data_store.cpp to match conditional compilation of S3-specific code.

The call site at line 347 is properly guarded with #ifdef DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3, but the AWS includes at lines 22–23 (#include <aws/core/client/ClientConfiguration.h> and #include <aws/s3/S3Client.h>) are unconditional. This creates a compilation failure when DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3 is not defined. Wrap these includes with the same preprocessor guard, matching the pattern in rocksdb_cloud_dump.cpp.

🧹 Nitpick comments (1)
eloq_data_store_service/rocksdb_cloud_data_store.cpp (1)

368-372: Add fallback for cloud type in error message.

If neither DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3 nor DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_GCS is defined, the error message will have an empty cloud type: "cloud type: , at path...". Consider adding an #else clause or #error directive.

Apply this diff to improve the error message:

 LOG(ERROR) << "Unable to create cloud storage filesystem, cloud type: "
 #if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3)
                    << "Aws"
 #elif defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_GCS)
                    << "Gcp"
+#else
+                   << "Unknown"
 #endif
                    << ", at path rocksdb_cloud with bucket "
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df8f2e2 and e353ff1.

📒 Files selected for processing (3)
  • eloq_data_store_service/rocksdb_cloud_data_store.cpp (6 hunks)
  • eloq_data_store_service/rocksdb_cloud_data_store.h (1 hunks)
  • eloq_data_store_service/rocksdb_cloud_dump.cpp (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • eloq_data_store_service/rocksdb_cloud_dump.cpp
🧰 Additional context used
🧬 Code graph analysis (1)
eloq_data_store_service/rocksdb_cloud_data_store.h (1)
eloq_data_store_service/rocksdb_cloud_data_store.cpp (2)
  • BuildS3ClientFactory (206-265)
  • BuildS3ClientFactory (206-207)
🔇 Additional comments (4)
eloq_data_store_service/rocksdb_cloud_data_store.h (1)

50-58: LGTM! Proper conditional compilation guard.

The BuildS3ClientFactory declaration is correctly wrapped in the S3-specific preprocessor guard, matching the implementation in the .cpp file. This ensures the method is only visible when building with S3 support, preventing compile-time and link-time errors.

eloq_data_store_service/rocksdb_cloud_data_store.cpp (3)

205-266: LGTM! S3-specific code properly guarded.

The BuildS3ClientFactory implementation is correctly wrapped in the S3 conditional compilation guard, ensuring it's only compiled when S3 support is enabled. This matches the corresponding header declaration.


276-299: LGTM! Status variable scope handling is correct.

The status variable is properly moved to an outer scope (line 276) and assigned within the S3 guard (line 291), then later assigned from NewCloudFileSystem (line 364). This pattern ensures the variable is available for both S3-specific credential validation and the common cloud filesystem initialization, with proper control flow in both build configurations.


343-359: LGTM! S3 endpoint configuration properly isolated.

The S3-specific endpoint and transfer manager configuration is correctly guarded, ensuring this code only compiles when S3 support is enabled.

Minor style note: This uses #ifdef while line 205 uses #if defined(). Both are equivalent but consider using consistent style throughout.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
eloq_data_store_service/rocksdb_cloud_dump.cpp (1)

144-151: Guard AWS credential validation with S3 conditional compilation.

AWS credential validation on lines 144-151 will cause GCP-only builds to fail at runtime, as these parameters won't be relevant for GCP. Wrap this validation block with #if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3).

Apply this diff:

+#if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3)
     // Validate required parameters
     if (params.aws_access_key_id.empty())
     {
         throw std::runtime_error("AWS access key ID is required");
     }
     if (params.aws_secret_key.empty())
     {
         throw std::runtime_error("AWS secret access key is required");
     }
+#endif
     if (params.bucket_name.empty())
     {
♻️ Duplicate comments (1)
eloq_data_store_service/rocksdb_cloud_dump.cpp (1)

423-424: LGTM! GCP filesystem creation parameter corrected.

The previous issue where cfs was passed instead of &cfs to NewGcpFileSystem has been fixed. Both S3 and GCP paths now correctly pass &cfs (pointer-to-pointer).

🧹 Nitpick comments (1)
eloq_data_store_service/rocksdb_cloud_dump.cpp (1)

45-53: Consider guarding AWS-specific flags with conditional compilation.

Flags like aws_access_key_id, aws_secret_key, region, and s3_endpoint are AWS-specific. While they don't break compilation in GCP builds, guarding them would improve clarity and prevent user confusion.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e353ff1 and 0e66799.

📒 Files selected for processing (1)
  • eloq_data_store_service/rocksdb_cloud_dump.cpp (9 hunks)
🔇 Additional comments (5)
eloq_data_store_service/rocksdb_cloud_dump.cpp (5)

23-26: LGTM! Correct conditional compilation for AWS includes.

The AWS SDK headers are properly guarded to prevent compilation when building for non-S3 cloud storage backends.


170-235: LGTM! S3 client factory properly isolated.

The buildS3ClientFactory function is correctly guarded and will only be compiled for S3 builds, preventing AWS SDK dependencies in GCP builds.


353-355: LGTM! Status variable correctly declared outside guards.

The status variable is used in both guarded and unguarded sections (credential validation, filesystem creation, error handling), so declaring it outside the conditional compilation blocks is correct.


408-415: LGTM! S3 endpoint configuration properly guarded.

The S3-specific endpoint configuration and client factory assignment are correctly isolated to S3 builds.


475-477: LGTM! AWS cleanup properly guarded across all exit paths.

All Aws::ShutdownAPI calls are correctly wrapped in S3 conditional compilation guards, matching the initialization at line 359. This ensures AWS SDK is only cleaned up when it was initialized.

Also applies to: 530-532, 642-644

@thweetkomputer thweetkomputer force-pushed the fix-gcs-compile branch 2 times, most recently from bd2585a to 87def1e Compare November 3, 2025 04:24
Copy link
Collaborator

@githubzilla githubzilla left a comment

Choose a reason for hiding this comment

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

+1

@thweetkomputer thweetkomputer merged commit 71f3fae into main Nov 4, 2025
1 check passed
@thweetkomputer thweetkomputer deleted the fix-gcs-compile branch November 4, 2025 05:12
@coderabbitai coderabbitai bot mentioned this pull request Dec 12, 2025
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.

2 participants