Recent comments posted to this site:
This is only a concern when --jobs is larger than --activerepositories. There have to be enough jobs running to max out --activerepositories. The default is for --activerepositories to be larger than --jobs.
So, any fix for this needs to be simple enough and low resource use enough to justify only improving that edge case. Otherwise forcing --activerepositories to be >= --jobs would be another way to solve this.
You know what... Let's just force that! Then we never have to worry about the shutdown getting stuck waiting on another request to finish.
It's better to take an inactive state, even one that was recently used, than to wait to shutdown an active state.
So, have a set that holds recently inactivated states. Remove states from it when they become active again, and when they get removed from the main LRU.
Then, if the set is not empty, can just take any state from the set, rather than popLRU, and shutdown will be guaranteed to be fast.
Hmm, on second thought, this would tend to put the most active repository states at the end of the LRU.
So it would be the next thing popped off the LRU when an active repository state needs to be shut down. Rather than a long-inactive state which has migrated to the middle of the LRU.
Demand loading Annex state would also allow freeing Annex state when a repository has not been accessed in a long time. As p2phttp scales to large numbers of repositories, the memory used for Annex states for each repository (times the number of jobs) might eventually become a scalability problem, so it would be good to have an architecture that allows freeing unused states.
And git-annex got a shiny new LRU cache implementation recently, that could be used for this.
Reopening as there is still a bug. More proxy connections get opened than closed, and the number can increase without bounds.
Can be reproduced with a proxyied external special remote, using:
while git-annex drop --force; git-annex get --from=origin-theremote -J2; done
The -J seems necessary, without concurrency there is no leak.
Looking at --debug, there are more "Opened proxy connection" than "Closed proxy connection".
cb5b92e9767fadec1baca0a4f463c52270b0ea3c had the problem, so later changes (to use LRU for proxy connections) did not cause a new bug.
Update: Fixed this one too.
Maybe another angle on this is that git-annex branch changes with incorrect information for the local repository should be automatically corrected.
Then the existing repository size tracking could be used for a quota (Ignoring keys w/o a stated size which could just be rejected from being received by a repository with a quota). Perhaps supplimented with the size of partially transferred objects.
Since calcBranchRepoSizes already sees all changes to location logs, it could just check if changes for the local repository are accurate. And journal a correction to the location log when they're not.
When the git-annex branch is updated locally, we know those changes are accurate, so it could skip the double checking them. That would make this have almost zero overhead.
The situation with proxied remotes is:
- --proxyconnections is the number of idle connections to cache. It is not a cap on the maximum number. If two requests come in to two different proxied remotes, a connection will be started to both, and once both are done, one of them will remain cached.
- --proxyconnections is per-repository, so even if it were an upper bound, there could be a lot of processes for proxied external special remotes
- Evicting a proxied connection from the pool doesn't stop the external
special remote process. This is because Remote.list is still populated,
and also Remote.External registers a cleanup action that stops it --
which is another reference and keeps it running until quiesce.
(I have a proof of concept fix for this in
p2phttpchill.)
I think that --proxyconnections can stay as an idle connections cache limit rather than an upper bound on the number of active connections. But make it be across all served repos, rather than per-repo.
It seems ok for the total number of proxy connections across all
repostories to be capped by the existing limits on the things that
use them. Basically that is --jobs + --lockedfiles. (With clusters,
--jobs * --clusterjobs + --lockfiles)
There needs to be a Map from a proxy remote to Annex state. When opening a proxy connection, do it in the Annex state for that particular proxy remote. That way, when a proxied connection is evicted from the pool, quiesce can be used to stop it, without also stopping other proxied connections or other stuff.
Update:
In p2phttpchill I've done some work toward the above now.
Implemented the proxy Map, and quiescing and GC. Then was able to avoid needing the GC, due to cleanup actions.
And made --proxyconnections be counted across all repositories.
And it all seems to be working now.
Got this implemented, except for proxied remotes.
Leaving the todo open for that.
Question: PerRepoServerState also has an annexState and annexRead that are not part of the AnnexWorkerPool so would not be affected by that. Are those used anywhere that spawns helper processes?
Unfortunately, it appears that they are. A git cat-file helper process
is started outside the AnnexWorkerPool, so there is one per served repository.
The flag is documented as "Build with memory rather than ram", so I don't see a problem with git-annex depending on memory as well as ram when the flag is not set. So I've made that change.