Skip to content

Commit

Permalink
lib/vmselectapi: do not send empty label names for labelNames request (
Browse files Browse the repository at this point in the history
…#4936)

* lib/vmselectapi: do not send empty label names for labelNames request
it breaks cluster communication, since vmselect incorrectly reads request buffer, leaving unread data on it
#4932

* typo fix

* wip

---------

Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
  • Loading branch information
f41gh7 and valyala committed Sep 1, 2023
1 parent d7cd7cc commit fac272b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Expand Up @@ -41,6 +41,7 @@ The following `tip` changes can be tested by building VictoriaMetrics components

* BUGFIX: [Official Grafana dashboards for VictoriaMetrics](https://grafana.com/orgs/victoriametrics): fix display of ingested rows rate for `Samples ingested/s` and `Samples rate` panels for vmagent's dasbhoard. Previously, not all ingested protocols were accounted in these panels. An extra panel `Rows rate` was added to `Ingestion` section to display the split for rows ingested rate by protocol.
* 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).
* BUGFIX: [vmstorage](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html): prevent from breaking `vmselect` -> `vmstorage` RPC communication when `vmstorage` returns an empty label name at `/api/v1/labels` request. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4932).

## [v1.93.2](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.2)

Expand Down
9 changes: 8 additions & 1 deletion lib/vmselectapi/server.go
Expand Up @@ -690,6 +690,10 @@ func (s *Server) processLabelNames(ctx *vmselectRequestCtx) error {

// Send labelNames to vmselect
for _, labelName := range labelNames {
if len(labelName) == 0 {
// Skip empty label names, since they may break RPC communication with vmselect
continue
}
if err := ctx.writeString(labelName); err != nil {
return fmt.Errorf("cannot write label name %q: %w", labelName, err)
}
Expand Down Expand Up @@ -741,7 +745,7 @@ func (s *Server) processLabelValues(ctx *vmselectRequestCtx) error {
// Send labelValues to vmselect
for _, labelValue := range labelValues {
if len(labelValue) == 0 {
// Skip empty label values, since they have no sense for prometheus.
// Skip empty label values, since they may break RPC communication with vmselect
continue
}
if err := ctx.writeString(labelValue); err != nil {
Expand Down Expand Up @@ -919,6 +923,9 @@ func (s *Server) processTenants(ctx *vmselectRequestCtx) error {

// Send tenants to vmselect
for _, tenant := range tenants {
if len(tenant) == 0 {
logger.Panicf("BUG: unexpected empty tenant name")
}
if err := ctx.writeString(tenant); err != nil {
return fmt.Errorf("cannot write tenant %q: %w", tenant, err)
}
Expand Down

0 comments on commit fac272b

Please sign in to comment.