-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Introducing object pool interface and refactor related code #36313
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
Conversation
|
Problems:
-> Refactor cat-file batch operations and support --batch-command approach #35775 |
The
This is because catfile is a sub package which cannot use
Adding a lock is straightforward, but is it actually correct to share a Repository instance across multiple goroutines?
Related to 3, I couldn't find when it need two processes. If it needs, why not create two
Sorry, I don't understand what you mean. I have rerun the CI multiple times, it will always succeed now and never encouter such failure. #34651 should have the problem but the code base are different.
PR #35775 has been accepted by me. However, this PR introduces a new concept, |
The old design is less fragile than this PR's newly introduced "Close"
I agree with that "The
It doesn't need to be in a new package. It only makes the system unnecessarily complex. That's why I removed the "catfile" package in 35775, then everything goes simple again, with no drawback.
If we are sure about those, and don't want to have these cases, then we need to aggressively check mistakes: report panics for developers to avoid such mistakes, which will be very difficult to debug.
It successds now because your In Golang, interface nil isn't nil. So the
I don't see ObjectPool really beyond 35775's CatFileBatch interface. The ObjectPool only stores more "ctx" into structs and will cause more problems. If you really like ObjectPool, you can add a few lines to wrap CatFileBatch to ObjectPool, they do not have any real difference. |
By the way, there are also other problems but I just don't want to write them more one by one. For example: when error occurs, you can't just do Close and set Incorrectly handling git process error is a longstanding problem , the old code is not right either, but we should not make it worse. |
I have considered this issue. At the moment, when an error occurs, the repository is closed, and all related subprocesses are terminated as well—regardless of whether they are individually broken or not. As a result, the page will display an error, but resources will not leak. I agree that for long-running tasks, relying solely on inUse is insufficient when a subprocess becomes broken. However, this is not a problem introduced by this PR; it has existed for a long time. I have therefore added it to the follow-up work planned as the next step after this PR. |
But sometimes, it needs more than 1 cat batch in the same go routine. Maybe it's a bug or resource leak. We can keep the warning here until we find and fix all the possible wrong usage.
Yes, if #35775 merged, I could rework this PR to do a wrap. |
The higher priority tasks are fixing these FIXMEs in 35775 Especially the "content reader" problem: it should be fully managed by the framework, callers should never need to call Close or Discard manually. |
If neither |
|
|
Too many conflicts. |
ObjectInfoto represent a git object information.ObjectPoolinterface to replaceBatch. The new interface haveObjectInfo,ObjectandClosemethods.batchObjectPoolwhich will invokegit catfile --batchorgit catfile --batch-checkwhen necessary.Next Steps(not this PR):
readCloserDiscardoperation toreadCloser'sClosemethodio.ReadCloserinstead ofReadCloseDiscarderafter above updatesObjectPoolas a field ofTreeCommonandBlobinstead ofRepositorygit catfile --batch-command