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

[pull] master from netdata:master #355

Merged
merged 6 commits into from
Feb 10, 2025
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Feb 10, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

Refactor disk I/O operations to avoid using a generic I/O descriptor and instead manage requests directly within each function. Update handling of ephemeral hostnames to skip unregistered ephemeral hostnames and free them based on age and registration status. Improve SQLite database initialization error handling and fix a potential issue with claim IDs when ACLK is offline.

Bug Fixes:

  • Fixed an issue where unregistered ephemeral hostnames were not skipped during loading.
  • Fixed a potential issue with claim IDs not being retrieved correctly when ACLK is offline.
  • Fixed an issue in SQLite database initialization where errors were not handled correctly, potentially leading to resource leaks.

Enhancements:

  • Refactored disk I/O operations to use function-specific request management, removing the need for a generic I/O descriptor.
  • Improved the handling of ephemeral hostnames during ACLK loading.

Ferroin and others added 6 commits February 10, 2025 16:27
The build is failing there at the moment with LTO enabled, so just skip
it.
* Close database if there is an error to prevent further operations on it during shutdown

* Better cleanup during initial open of the database
* Use local request and buffer

* Cleanup structures/fields not needed (no callbacks to pass data)

* Cleanup request before retrying
…oud connectivity) (#19611)

use the parent claim id when agent is claimed but not connected to netdata cloud
* If unregistered during startup and it was removed by cli or cleanup, do not register again

* Code cleanup
@pull pull bot added the ⤵️ pull label Feb 10, 2025
Copy link

sourcery-ai bot commented Feb 10, 2025

Reviewer's Guide by Sourcery

This PR refactors several I/O and error handling routines, enhances claim ID retrieval logic, updates logging and configuration settings, and cleans up deprecated structures. The changes address asynchronous file-writing in journal operations and extent writes, improve SQLite error management, standardize claim identifier handling, and modify streaming alert targets.

Sequence diagram for asynchronous extent write process

sequenceDiagram
    participant W as Worker (extent_write_tp_worker)
    participant D as Datafile
    participant FS as uv_fs_write()
    participant J as Journalfile (journalfile_v1_extent_write)

    W->>FS: Call uv_fs_write() to write extent data
    alt Write fails
        FS-->>W: Error result
        W->>W: sleep and uv_fs_req_cleanup()
        loop Retries
            W->>FS: Retry uv_fs_write()
            alt Still failing
                FS-->>W: Error result
                W->>W: sleep and cleanup
            else Write succeeds
                FS-->>W: Success result
            end
        end
    else Write succeeds
        FS-->>W: Success result
    end
    W->>W: Check write result and log errors if any
    W->>J: Call journalfile_v1_extent_write() to write metadata
    W->>W: Invoke extent_flush_to_open() for post-write handling

    note right of W: Asynchronous retries and error handling
Loading

Updated extent_io_descriptor class diagram

classDiagram
    class extent_io_descriptor {
        +rrdengine_instance *ctx
        +void *buf
        +uint64_t pos
        +unsigned descr_count
        +unsigned bytes
        +struct wal *wal
        +uv_file file
        +struct page_descr_with_data *descr_array[MAX_PAGES_PER_EXTENT]
        +struct rrdengine_datafile *datafile
    }

    note for extent_io_descriptor "Removed fields: uv_fs_t uv_fs_request and uv_buf_t iov\nUpdated ordering of fields for clarity."
Loading

File-Level Changes

Change Details Files
Refactored asynchronous journal file write logic
  • Replaced the generic I/O descriptor with a local uv_fs_t request and uv_buf_t buffer for writing to the journal file
  • Adjusted the logic for simulating an empty transaction and updating file positions under a spinlock
  • Improved error handling within the retry loop by cleaning up the uv_fs_t request after failures
  • Updated logging format specifiers for reporting file offsets more accurately
src/database/engine/journalfile.c
Refactored extent write and flush processes
  • Renamed extent_flushed_to_open_tp_worker to extent_flush_to_open for clarity
  • Updated datafile_extent_build to accept a uv_buf_t pointer and removed obsolete assignments
  • Replaced use of the uv_fs_request field with a local uv_fs_t request variable in extent writes
  • Aligned error handling and cleanup logic in extent_write_tp_worker with the new request variable
src/database/engine/rrdengine.c
src/database/engine/rrdengine.h
Improved error handling in SQLite metadata initialization
  • Replaced early returns with a goto-based cleanup to ensure proper closure of the database on error
  • Ensured that sqlite3_close is always called on failure, resetting the database pointer appropriately
src/database/sqlite/sqlite_metadata.c
Adjusted ephemeral host handling in SQLite ACL logic
  • Modified conditional checks to add a cleanup step via goto instead of an immediate return for unregistered ephemeral hosts
  • Clarified the conditions under which host data is processed or skipped
src/database/sqlite/sqlite_aclk.c
Updated alert target configuration
  • Changed alert targets in the streaming configuration from 'sysadmin' to 'silent' for both ephemeral hosts and permanent child nodes
src/health/health.d/streaming.conf
Enhanced claim ID retrieval logic
  • Adjusted conditions in claim_id_get to use the parent claim ID when the host UUID is zero or when offline conditions are met
src/claim/claim_id.c
Standardized claim ID usage in cloud status reporting
  • Replaced a generic claim_id_get call with rrdhost_claim_id_get(localhost) for consistency in retrieving the claim ID
src/claim/cloud-status.c
Unified claim ID retrieval in registry requests
  • Replaced the use of claim_id_get with rrdhost_claim_id_get(host) to ensure robust claim ID management during registry operations
src/registry/registry.c
Updated package spec file
  • Applied minor adjustments to the spec file to align with the recent changes in the codebase
netdata.spec.in

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@pull pull bot merged commit 250d1bd into webfutureiorepo:master Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants