{"record":{"id":"309791d93f761935","repo":"crowdsecurity/crowdsec","slug":"while-starting-victorialogs-tail-w","errorCode":null,"errorMessage":"while starting VictoriaLogs tail: %w","messagePattern":"while starting VictoriaLogs tail: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/victorialogs/run.go","lineNumber":106,"sourceCode":"\t}\n\n\tlctx, clientCancel := context.WithCancel(ctx)\n\t// Don't defer clientCancel(), the client outlives this function call\n\n\tt.Go(func() error {\n\t\t<-t.Dying()\n\t\tclientCancel()\n\n\t\treturn nil\n\t})\n\n\tt.Go(func() error {\n\t\trespChan, err := s.getResponseChan(lctx, true)\n\t\tif err != nil {\n\t\t\tclientCancel()\n\t\t\ts.logger.Errorf(\"could not start VictoriaLogs tail: %s\", err)\n\n\t\t\treturn fmt.Errorf(\"while starting VictoriaLogs tail: %w\", err)\n\t\t}\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase resp, ok := <-respChan:\n\t\t\t\tif !ok {\n\t\t\t\t\ts.logger.Warnf(\"VictoriaLogs channel closed\")\n\t\t\t\t\tclientCancel()\n\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\ts.readOneEntry(resp, s.Config.Labels, out)\n\t\t\tcase <-t.Dying():\n\t\t\t\tclientCancel()\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/victorialogs/run.go#L88-L124","documentation":"Inside the streaming goroutine, the initial call to `getResponseChan` (tail start) failed, so the whole streaming acquisition goroutine returns an error into the tomb and the datasource shuts down. This wraps the same tail transport/HTTP failures as the client-level errors.","triggerScenarios":"`s.getResponseChan(lctx, true)` errors on the initial `Client.Tail` call: VictoriaLogs unreachable or answering non-200 after retries, or `lctx` already canceled because the tomb is dying / clientCancel fired.","commonSituations":"VictoriaLogs restarting exactly when the streamer opens its tail; wrong URL/port in config; network outage at crowdsec start; the lctx canceled by a prior shutdown, producing a benign wrapped cancel error.","solutions":["Fix the wrapped root cause (connectivity, HTTP status, query) reported in the accompanying 'could not start VictoriaLogs tail' log line.","Confirm the tail endpoint: `curl -N '<url>/select/logsql/tail?query=...'` streams SSE.","Check crowdsec logs for whether the tomb was already dying (shutdown race) — if so the error is expected noise during reload/stop.","Verify config `url`, `prefix`, `query` and auth settings.","Restart crowdsec once VictoriaLogs is confirmed healthy."],"exampleFix":"// before\nurl: http://127.0.0.1:9429\n// after\nurl: http://127.0.0.1:9428  # correct VictoriaLogs HTTP port","handlingStrategy":"retry","validationCode":"// pre-flight the tail endpoint\nresp, err := http.Get(cfg.URL + \"/select/logsql/tail?limit=1&query=\" + url.QueryEscape(cfg.Query))\nif err != nil || resp.StatusCode != 200 { return err }","typeGuard":null,"tryCatchPattern":"err := t.Go(func() error { ... })\n// on tomb error:\nif errors.Is(err, context.Canceled) { return nil } // shutdown race, ignore","preventionTips":["Verify the tail endpoint streams before going live","Ignore context-canceled errors during reload/stop","Keep VL reachable at crowdsec start (healthchecks)","Fix config after reading the inner root error"],"tags":["streaming","victorialogs","tail","startup"],"backgroundTag":"api-request-failed","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}