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

test: Ensure that all databases are always closed on exit #1187

Merged
merged 1 commit into from
Mar 16, 2023

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #1186

Description

Ensures that all databases are always closed on exit.

This is really important for file based datastores, and failure to close even a couple will have a highly significant performance impact due to a long-term defra bug, where if the directory hosting defra is deleted whilst a database instance is active the instance will hang/infinite-loop chewing up a huge amount of resources. As the file based directories are deleted by go test at the end of each test, this magnifies the effect of any lingering instances. In the case of this issue I believe only a very small number of databases were leaked, yet it nearly doubled the execution time of the change detector (the only potential leaks I found were a couple of panics, and a couple of subscription tests, it could be that as few as 3-4 leaked databases were responsible for the loss of performance).

Tested by executing the change detector by targeting this branch. The change detector will likely be slow in this PR and the problem will only be resolved upon merge to develop (as the issue is most visible in change detector startup).

@AndrewSisley AndrewSisley added bug Something isn't working area/testing Related to any test or testing suite action/no-benchmark Skips the action that runs the benchmark. labels Mar 16, 2023
@AndrewSisley AndrewSisley added this to the DefraDB v0.5 milestone Mar 16, 2023
@AndrewSisley AndrewSisley requested a review from a team March 16, 2023 19:04
@AndrewSisley AndrewSisley self-assigned this Mar 16, 2023
Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link

codecov bot commented Mar 16, 2023

Codecov Report

Merging #1187 (4af5447) into develop (f01563b) will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1187      +/-   ##
===========================================
+ Coverage    68.76%   68.79%   +0.02%     
===========================================
  Files          180      180              
  Lines        17046    17046              
===========================================
+ Hits         11722    11727       +5     
+ Misses        4372     4368       -4     
+ Partials       952      951       -1     

see 1 file with indirect coverage changes

@AndrewSisley AndrewSisley force-pushed the sisley/fix/I1186-change-detector-leak branch from 4d6ff7a to 4af5447 Compare March 16, 2023 19:18
This is really important for file based datastores, and failure to close even a couple will have a highly significant performance impact due to a long-term defra bug, where if the directory hosting defra is deleted whilst a database instance is active the instance will hang/infinate-loop chewing up a huge amount of resources. As the file based directories are deleted by `go test` at the end of each test, this magnifies the effect of any lingering instances.  In the case of this issue I believe only a very small number of databases were leaked, yet it nearly doubled the execution time of the change detector (the only potential leaks I found were a couple of panics, and a couple of subscription tests, it could be that as few as 3-4 leaked databases were responsible for the loss of performance).
@AndrewSisley
Copy link
Contributor Author

AndrewSisley commented Mar 16, 2023

Sorry about the holdup, I moved the defer function from an inline declaration to a proper function shortly before opening the PR and my local runtimes have shot up again. Still trying to figure out why

@AndrewSisley
Copy link
Contributor Author

Sorry about the holdup, I moved the defer function from an inline declaration to a proper function shortly before opening the PR and my local runtimes have shot up again. Still trying to figure out why

Branch without the breaking commit is now taking 15min locally... I'm just going to merge this and see if it sorts it. Is a good enough change to have anyway

@AndrewSisley AndrewSisley merged commit 08c4b8b into develop Mar 16, 2023
@AndrewSisley AndrewSisley deleted the sisley/fix/I1186-change-detector-leak branch March 16, 2023 22:55
shahzadlone pushed a commit that referenced this pull request Apr 13, 2023
This is really important for file based datastores, and failure to close even a couple will have a highly significant performance impact due to a long-term defra bug, where if the directory hosting defra is deleted whilst a database instance is active the instance will hang/infinate-loop chewing up a huge amount of resources. As the file based directories are deleted by `go test` at the end of each test, this magnifies the effect of any lingering instances.  In the case of this issue I believe only a very small number of databases were leaked, yet it nearly doubled the execution time of the change detector (the only potential leaks I found were a couple of panics, and a couple of subscription tests, it could be that as few as 3-4 leaked databases were responsible for the loss of performance).
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
…ork#1187)

This is really important for file based datastores, and failure to close even a couple will have a highly significant performance impact due to a long-term defra bug, where if the directory hosting defra is deleted whilst a database instance is active the instance will hang/infinate-loop chewing up a huge amount of resources. As the file based directories are deleted by `go test` at the end of each test, this magnifies the effect of any lingering instances.  In the case of this issue I believe only a very small number of databases were leaked, yet it nearly doubled the execution time of the change detector (the only potential leaks I found were a couple of panics, and a couple of subscription tests, it could be that as few as 3-4 leaked databases were responsible for the loss of performance).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/testing Related to any test or testing suite bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change detector setup stage performance significantly degraded
3 participants