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

Refactoring and deadlock solution of wazuhDBWrapper #23358

Merged
merged 12 commits into from
May 13, 2024

Conversation

GabrielEValenzuela
Copy link
Member

@GabrielEValenzuela GabrielEValenzuela commented May 9, 2024

Related issue
#23301

Objective

This PR aims to overhaul the socketDBWrapper class by implementing a blocking approach to socket operations and converting the class to use a singleton pattern. This refactor enhances the efficiency and manageability of socket interactions throughout our application. Additionally, we have refactored the unit tests to align with these changes and ensure comprehensive coverage and reliability.

Description

  • The existing implementation of the socketDBWrapper class was identified as a deadlock, particularly in scenarios with high concurrency and rapid socket operations.
  • To address these issues, we have refactored the socketDBWrapper to a blocking model, which simplifies the management of socket operations and ensures that each operation is completed before proceeding. This change is expected to improve the stability and performance of network communications.
  • Moreover, we have converted the socketDBWrapper into a singleton to prevent multiple instances from being created. This ensures that socket operations are centralized and managed consistently throughout the application's lifecycle.
  • The unit tests for socketDBWrapper were also overhauled to reflect these changes. New tests were added to specifically assess the blocking behavior and the singleton instance management, ensuring that the class functions correctly under various scenarios and that thread safety and singleton properties are maintained.

Quality Assurance

Static Analysis

  • The refactored code underwent thorough static analysis to ensure that it adheres to best coding practices and standards. Special attention was paid to thread safety and synchronization mechanisms, given the transition to a blocking approach and singleton usage.

Testing

Unit Testing

  • Specific tests were designed to ensure that the singleton instance is properly created and accessed and that no additional instances are instantiated throughout the application's operation.

Integration Testing

N/A


@GabrielEValenzuela GabrielEValenzuela self-assigned this May 9, 2024
@GabrielEValenzuela GabrielEValenzuela linked an issue May 9, 2024 that may be closed by this pull request
@GabrielEValenzuela GabrielEValenzuela marked this pull request as ready for review May 11, 2024 00:09
GabrielEValenzuela and others added 7 commits May 12, 2024 23:29
- Refactor wazuhDbWrapper
- Refactor UTs.
- Refactor UTs. Fix errors.
- Fix memleak.
- Refactor of code and UTs fix.
- Remove cerr line.
@Dwordcito Dwordcito force-pushed the bug/23301_deadlock_wazuhdbwrapper branch from 48fa0da to 338fba5 Compare May 13, 2024 03:14
- Fix QA test output and format.
Copy link
Member

@sebasfalcone sebasfalcone left a comment

Choose a reason for hiding this comment

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

Nice work @GabrielEValenzuela!

sebasfalcone and others added 4 commits May 13, 2024 16:16
- Fix QA test output (removed white spaces)
…wazuh into bug/23301_deadlock_wazuhdbwrapper
- Apply review comments.
@Dwordcito Dwordcito merged commit bc23bfe into 4.8.0 May 13, 2024
86 of 87 checks passed
@Dwordcito Dwordcito deleted the bug/23301_deadlock_wazuhdbwrapper branch May 13, 2024 23:48
sebasfalcone added a commit that referenced this pull request May 15, 2024
- Fixed class name
- Aligned with changes from #23358 after rebase
pereyra-m pushed a commit that referenced this pull request May 16, 2024
- Fixed class name
- Aligned with changes from #23358 after rebase
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.

Wazuh-db errors logs in Footprint tests
3 participants