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

Add some way to clear cache without remounting #6

Open
JuniorJPDJ opened this issue Sep 1, 2020 · 11 comments
Open

Add some way to clear cache without remounting #6

JuniorJPDJ opened this issue Sep 1, 2020 · 11 comments
Labels
enhancement New feature or request

Comments

@JuniorJPDJ
Copy link
Contributor

First thing that came up to my mind was to open some invisible virtual file in main directory.
eg. echo "" > ./.clean_ziprofs_cache
Of course .clean_cache wouldn't be listed in readdir() call

At the moment when I remount underlying filesystem (which was pretty often bcs of bugs in it) I need to remount also ZipROFS and restart all software which was using it.
Some workaroundish way to clean cache and reopen existing handles would be helpful.

@qu1ck
Copy link
Member

qu1ck commented Sep 2, 2020

Probably handling SIGHUP to dump cache is as close to a convention as we can get. At least it's better then creating some special meaning files.

By the way you will probably still have to restart software using ziprofs because it likely doesn't handle file handles becoming invalid well. Software that can handle that also survives ziprofs restart as I can attest from my everyday usage.

@JuniorJPDJ
Copy link
Contributor Author

We could close any cached files and refresh handles inside ZipROFS to make this seamless

@JuniorJPDJ
Copy link
Contributor Author

The solution I've in my mind is clearing cache and freezing ZipROFS process until underlying FS remounts

@qu1ck
Copy link
Member

qu1ck commented Sep 2, 2020

I don't think there is a way for ziprofs to distinguish between empty root and not mounted root. So freeze/unfreeze triggers have to be external, you could use SIGUSR1/2 for that.

@JuniorJPDJ
Copy link
Contributor Author

I meant just freezing whole process with SIGSTOP :D

@qu1ck
Copy link
Member

qu1ck commented Sep 2, 2020

That works too but then you can't clear cache while the process is frozen.

@JuniorJPDJ
Copy link
Contributor Author

JuniorJPDJ commented Sep 2, 2020

I would guess it would process SIGUSR before anything other after unfreezing.
We could also provide SIGTSTP as it is being handled by process - which would first clear cache, then freeze process.

@qu1ck
Copy link
Member

qu1ck commented Sep 2, 2020

I would guess it would process SIGUSR before anything other after unfreezing.

Unless this is documented behavior I wouldn't count on it.

We could also provide SIGTSTP as it is being handled by process - which would first clear cache, then freeze process.

I would rather go for more generic solution. Sometimes dumping cache is useful without freezing process, these operations shouldn't be tied together.

@JuniorJPDJ
Copy link
Contributor Author

Yes, but it could be function called twice, for SIGUSR and SIGTSTP.

@qu1ck qu1ck added the enhancement New feature or request label Sep 3, 2020
@qu1ck
Copy link
Member

qu1ck commented Sep 3, 2020

So this sounds like a plan:

  1. Handle SIGHUP to drop cache
  2. Handle SIGTSTP to freeze and drop cache
  3. Handle SIGCONT to unfreeze and attempt to refresh file handles

For refreshing file handles I think we will have to try to refresh non-zip handles as well. For that we will need a mapping of ziprofs handles to system handles instead of current odd-even scheme.

But I probably won't have time to implement this stuff in a while.

@JuniorJPDJ
Copy link
Contributor Author

We could just drop and zipfiles instead of holding next handles.
Those are just open ZipFiles which we can close and reopen using cached implementation if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants