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

Closes: Feature: add ability to delete apps #119 #221

Merged
merged 10 commits into from
Jun 3, 2021

Conversation

AdrK
Copy link
Contributor

@AdrK AdrK commented May 27, 2021

No description provided.

@AdrK AdrK linked an issue May 27, 2021 that may be closed by this pull request
@AdrK AdrK changed the title Draft Closes: Feature: add ability to delete apps #119 May 27, 2021
@codecov
Copy link

codecov bot commented May 27, 2021

Codecov Report

Merging #221 (360ab99) into main (9c89c4b) will increase coverage by 0.10%.
The diff coverage is 67.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #221      +/-   ##
==========================================
+ Coverage   55.98%   56.07%   +0.10%     
==========================================
  Files          74       74              
  Lines        3053     3089      +36     
==========================================
+ Hits         1709     1732      +23     
- Misses       1176     1186      +10     
- Partials      168      171       +3     
Impacted Files Coverage Δ
pkg/storage/cache/cache.go 67.54% <0.00%> (-4.68%) ⬇️
pkg/storage/storage.go 63.01% <77.15%> (+2.26%) ⬆️
pkg/agent/upstream/remote/remote.go 64.62% <0.00%> (-3.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a550356...360ab99. Read the comment docs.

@AdrK AdrK force-pushed the 119_feature_add_ability_to_delete_apps branch 4 times, most recently from dfbafc9 to e19f7cb Compare May 27, 2021 16:50
@AdrK AdrK force-pushed the 119_feature_add_ability_to_delete_apps branch from e19f7cb to 8b8fe61 Compare May 27, 2021 16:51
@@ -76,6 +76,24 @@ func (cache *Cache) Flush() {
<-cache.cleanupDone
}

func (cache *Cache) Delete(key string) {
cache.Flush()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This causes an EvictionChannel to be closed. How to remove the entries from cache in different way?

Copy link
Member

Choose a reason for hiding this comment

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

Flush will clear the whole cache if I understand it correctly. I don't see a Delete function in lfu-go which is a bummer. It should be easy to add though.

We can add it to our fork of lfu-go https://github.com/pyroscope-io/lfu-go The function should just do something like this:

c.lock.Lock()
defer c.lock.Unlock()
delete(c.values, key)

To make the project use our fork we'll need to make changes to go.mod the same way we use this revive fork:
https://github.com/pyroscope-io/pyroscope/blob/main/go.mod#L48

Copy link
Contributor Author

@AdrK AdrK May 28, 2021

Choose a reason for hiding this comment

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

allright, I have it done locally, but I need write access to lfu-go to commit it. I have updated cache.go, but I expect test to fail until the fork will be updated.
Edit:
I have used my own fork, and seems that it works, at least in tests.

go.mod Outdated
@@ -46,3 +46,5 @@ require (
)

replace github.com/mgechev/revive v1.0.3 => github.com/pyroscope-io/revive v1.0.6-0.20210330033039-4a71146f9dc1

replace github.com/dgrijalva/lfu-go => github.com/AdrK/lfu-go v1.0.0-test
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be replaced with proper fork

Copy link
Collaborator

@kolesnikovae kolesnikovae left a comment

Choose a reason for hiding this comment

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

LGTM.

s.closingMutex.Lock()
defer s.closingMutex.Unlock()

if s.closing {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not related to the change itself but I'm wondering if we really need to keep closingMutex acquired during the whole call. I think we can benefit from replacing the Mutex with an RWMutex, at least. Do other functions (apart from Close) actually compete? If so, should we rename it accordingly (just m/mu)?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this is a very good point. The idea was to make sure we don't try to read / write after Close is called.

But the way it is currently implemented, we basically have a lock on the whole db... I changed it to a RWMutex.

Good news is that this means we'll get better performance. Bad news is that this might now expose some bugs that were hidden before because we had a lock on the whole db. Hopefully unit tests + running pyroscope server locally will expose those.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, that's my biggest concern. We can mitigate the risk by using RLock in Get only.

Also, I think Close should acquire the mutex for the whole call.

Copy link
Member

Choose a reason for hiding this comment

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

If Close acquires mutex for the whole call, then Get and Put will just block instead of returning errors... I think I'd rather them returning errors..

We can mitigate the risk by using RLock in Get only.

I'll do some tests today. One thing I can tell already is that if I benchmark it nothing breaks. That's good, but is not a 100% guarantee.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering also about a situation when we remove from cache, but not yet from disk. If in the middle someone would call a read, cache would read from disk, reloading an item that was previously deleted. And at the end, we will in fact remove from disk, but we end up with not removed item in cache.

@petethepig petethepig marked this pull request as ready for review June 2, 2021 03:39
@petethepig petethepig merged commit 2cc5f0e into main Jun 3, 2021
@petethepig petethepig deleted the 119_feature_add_ability_to_delete_apps branch June 3, 2021 00:33
korniltsev pushed a commit that referenced this pull request Jul 18, 2023
Ensure stacktraces parquet table is delta binary packed
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.

Feature: add ability to delete apps
3 participants