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 #285

Merged
merged 4 commits into from
Jan 10, 2025
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Jan 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

Improve metrics cardinality calculations, context loading time during startup, and fix memory corruption in the database engine. Update the streaming thread to resize message arrays safely. Fix file descriptor leaks and correct a function name in the kickstart script.

Bug Fixes:

  • Prevent memory corruption in the database engine.
  • Fix file descriptor leaks.
  • Correct a function name in the kickstart script.
  • Prevent leading comma in Docker LABELS when IMAGE is empty.
  • Fix variable scope to prevent invalid memory access.
  • Delay collecting all virtual interfaces.

stelfrag and others added 4 commits January 10, 2025 11:48
* Improve context load time during startup

* Remove cache for instance acquired

---------

Co-authored-by: Costa Tsaousis <[email protected]>
* metrics cardinality improvements

* fix ephemerality of metrics calculation
@pull pull bot added the ⤵️ pull label Jan 10, 2025
@pull pull bot merged commit 32c5b0a into webfutureiorepo:master Jan 10, 2025
Copy link

sourcery-ai bot commented Jan 10, 2025

Reviewer's Guide by Sourcery

This pull request includes several improvements and fixes related to metrics cardinality, context loading, memory handling, and more.

Sequence diagram for improved context loading process

sequenceDiagram
    participant H as Host
    participant T as Thread Pool
    participant DB as SQLite DB

    H->>T: Request context load
    activate T
    Note over T: Thread local SQLite connections
    T->>DB: Open meta DB connection
    T->>DB: Open context DB connection
    T->>DB: Load context data
    DB-->>T: Return context data
    T->>H: Update host context
    deactivate T
    Note over T: Close DB connections
    Note over T: Clear thread local vars
Loading

Class diagram for host context loading structure

classDiagram
    class host_context_load_thread {
        +uv_thread_t thread
        +RRDHOST* host
        +sqlite3* db_meta_thread
        +sqlite3* db_context_thread
        +bool busy
        +bool finished
    }

    class RRDHOST {
        +host_data
    }

    host_context_load_thread --> RRDHOST: loads context for
Loading

State diagram for thread lifecycle in context loading

stateDiagram-v2
    [*] --> Idle
    Idle --> Busy: Thread assigned
    Busy --> Loading: Open DB connections
    Loading --> Processing: Load context data
    Processing --> Cleanup: Context loaded
    Cleanup --> Idle: Close connections
    Cleanup --> [*]: Thread finished
Loading

File-Level Changes

Change Details Files
Improved context load time during startup by enabling multi-threading for context restoration.
  • Introduced thread-local variables for database connections to avoid contention.
  • Added logic to distribute context loading across multiple threads.
  • Modified cleanup routine to handle thread-local variables correctly.
src/database/sqlite/sqlite_metadata.c
Enhanced metrics cardinality calculations to provide more accurate and detailed information.
  • Improved counting of online and offline instances and metrics.
  • Added calculation of ephemerality for both instances and metrics.
  • Updated the API response to include separate ephemerality values.
src/web/api/functions/function-metrics-cardinality.c
Improved handling of database connections in context-related functions.
  • Used thread-local database connections for improved performance and thread safety.
  • Replaced compiled statements with regular statements for thread safety.
src/database/sqlite/sqlite_context.c
Fixed a potential memory issue in the streaming thread message handling.
  • Added a spinlock to protect message resizing operations.
  • Ensured thread safety during message queue resizing.
src/streaming/stream-thread.c

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

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