mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
app/vminsert: properly close vmstorage connection (#4935)
* app/vminsert: properly close vmstorage connection previously vmstorage may stuck in broken state until vminsert restarts since vmstorage was marked as read-only and connection was broken to it. checkReadonly function never marked connection as broken https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4870 * wip --------- Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
This commit is contained in:
parent
d34ffb8f98
commit
561dd2900a
2 changed files with 17 additions and 2 deletions
|
@ -808,9 +808,22 @@ func (sn *storageNode) checkReadOnlyMode() {
|
||||||
atomic.StoreUint32(&sn.isReadOnly, 0)
|
atomic.StoreUint32(&sn.isReadOnly, 0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !errors.Is(err, errStorageReadOnly) {
|
if errors.Is(err, errStorageReadOnly) {
|
||||||
logger.Errorf("cannot check storage readonly mode for -storageNode=%q: %s", sn.dialer.Addr(), err)
|
// The storage remains in read-only mode
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// There was an error when sending nil buf to the storage.
|
||||||
|
logger.Errorf("cannot check storage readonly mode for -storageNode=%q: %s", sn.dialer.Addr(), err)
|
||||||
|
|
||||||
|
// Mark the connection to the storage as broken.
|
||||||
|
if err = sn.bc.Close(); err != nil {
|
||||||
|
cannotCloseStorageNodeConnLogger.Warnf("cannot close connection to storageNode %q: %s", sn.dialer.Addr(), err)
|
||||||
|
}
|
||||||
|
sn.bc = nil
|
||||||
|
atomic.StoreUint32(&sn.broken, 1)
|
||||||
|
sn.brCond.Broadcast()
|
||||||
|
sn.connectionErrors.Inc()
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -15,6 +15,8 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
||||||
|
|
||||||
## v1.87.x long-time support release (LTS)
|
## v1.87.x long-time support release (LTS)
|
||||||
|
|
||||||
|
* BUGFIX: [vminsert](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html): properly close broken vmstorage connection during [read-only state](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#readonly-mode) checks at `vmstorage`. Previously it wasn't properly closed, which prevents restoring `vmstorage` node from read-only mode. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4870).
|
||||||
|
|
||||||
## [v1.87.8](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.87.8)
|
## [v1.87.8](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.87.8)
|
||||||
|
|
||||||
Released at 2023-09-01
|
Released at 2023-09-01
|
||||||
|
|
Loading…
Reference in a new issue