optimize shim lock in exec to avoid exec hang#2820
optimize shim lock in exec to avoid exec hang#2820lifubang wants to merge 2 commits intocontainerd:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2820 +/- ##
=======================================
Coverage 43.79% 43.79%
=======================================
Files 100 100
Lines 10741 10741
=======================================
Hits 4704 4704
Misses 5307 5307
Partials 730 730
Continue to review full report at Codecov.
|
|
containerd/runtime/v1/shim/service.go Lines 248 to 256 in c206da7 For example: s.processes[r.ID]=&execProcess{}And delete it if Exec error. |
|
Or: for avoid global shim lock, I think we may just add a new lock(such as: s.execmu) just for Exec func, because it's different from other func. |
|
If we are confident that |
|
Does same exec id should be consider in the upper level, like moby? I am not sure |
Yes, moby have consider it, each exec id is different from each other. |
|
@lifubang this needs a rebase please. thanks! |
Signed-off-by: Lifubang <[email protected]>
2fe5c8d to
0511bdd
Compare
have done, thanks. |
|
I've been looking through this code recently, I don't think we want to hold the lock during execution but we should maybe "reserve" the id at the entrypoint of the Exec. I'm going to try updating this for this functionality. |
ref containerd#2820 Signed-off-by: Michael Crosby <[email protected]>
ref containerd#2820 Signed-off-by: Michael Crosby <[email protected]>
Exec shim lock optimize before may cause two exec operations can enter to process.Exec area with the same exec id. (With small probability)
Please see:
containerd/runtime/v1/shim/service.go
Lines 247 to 276 in c206da7
They can both enter here:
containerd/runtime/v1/shim/service.go
Line 261 in c206da7
Because the exec id has not been added to s.processes:
containerd/runtime/v1/shim/service.go
Line 273 in c206da7
This will cause one of exec hang when exit:
This one can exit succ:
This one can't exit:
So, I think this lock should be for the whole func, and just one exec can run succ, the other one should return an error.
But this is not important for docker, because each exec id in docker are different.
If maintainers feel it's not really important because of some other factors, this can be ignored. Because it's really a very small probability.