mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 04:05:40 +01:00
ef6414be3e
During the harbor core initialization if the database takes longer to be ready there is a risk of deadlock when checking for the TCP connection with the database. The `TestTCPConn` function uses unbuffered channels to check when the connection succeeds/timeouts. The timeout check is executed in parallel with the connection check (this runs in a gorountine). The deadlock happens when the goroutine execution takes longer than the function timeout (hence setting `cancel <- 1`) and the DialTimeout call succeeds (hence setting `success <- 1`). At this point both threads are waiting for the channels values to be read. This is reproducible mostly on slow systems where initializing the database takes longer and finishes during the 5th time of the `DialTimeout` call where it eventually exceeds the TestTCPConn timeout. This fix sets the `success` and `cancel` channels as buffered (non-blocking). Signed-off-by: Flávio Ramalho <framalho@suse.com> |
||
---|---|---|
.. | ||
chartserver | ||
cmd | ||
common | ||
controller | ||
core | ||
jobservice | ||
lib | ||
migration | ||
pkg | ||
portal | ||
registryctl | ||
replication | ||
server | ||
testing | ||
vendor | ||
favicon.ico | ||
go.mod | ||
go.sum |