{"record":{"id":"6011ab50a79dc344","repo":"crowdsecurity/crowdsec","slug":"while-setting-last-pull-timestamp-for-blocklist-s","errorCode":null,"errorMessage":"while setting last pull timestamp for blocklist %s: %w","messagePattern":"while setting last pull timestamp for blocklist (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apiserver/apic.go","lineNumber":988,"sourceCode":"\n\tdecisions, hasChanged, err := client.Decisions.GetDecisionsFromBlocklist(ctx, blocklist, lastPullTimestamp)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"while getting decisions from blocklist %s: %w\", *blocklist.Name, err)\n\t}\n\n\tif !hasChanged {\n\t\tif lastPullTimestamp == \"\" {\n\t\t\tlog.Infof(\"blocklist %s hasn't been modified or there was an error reading it, skipping\", *blocklist.Name)\n\t\t} else {\n\t\t\tlog.Infof(\"blocklist %s hasn't been modified since %s, skipping\", *blocklist.Name, lastPullTimestamp)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\terr = a.dbClient.SetConfigItem(ctx, blocklistConfigItemName, time.Now().UTC().Format(http.TimeFormat))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"while setting last pull timestamp for blocklist %s: %w\", *blocklist.Name, err)\n\t}\n\n\tif len(decisions) == 0 {\n\t\tlog.Infof(\"blocklist %s has no decisions\", *blocklist.Name)\n\t\treturn nil\n\t}\n\t// apply APIC specific whitelists\n\tdecisions = a.ApplyApicWhitelists(ctx, decisions)\n\talert := createAlertForDecision(decisions[0], types.CAPIAlertKind)\n\talertsFromCapi := []*models.Alert{alert}\n\talertsFromCapi = fillAlertsWithDecisions(alertsFromCapi, decisions, addCounters)\n\n\terr = a.SaveAlerts(ctx, alertsFromCapi, addCounters, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"while saving alert from blocklist %s: %w\", *blocklist.Name, err)\n\t}\n\n\treturn nil","sourceCodeStart":970,"sourceCodeEnd":1006,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiserver/apic.go#L970-L1006","documentation":"Wraps the error from dbClient.SetConfigItem when storing the new `blocklist:<name>:last_pull` timestamp after a successful pull. The inner error is a database write failure (DB unavailable, constraint error, context cancelled).","triggerScenarios":"updateBlocklist finished pulling decisions and writes the current UTC time as config item; the DB write fails, e.g. SQLite read-only filesystem, disk full, connection lost.","commonSituations":"Disk full or read-only mount on the SQLite file, PostgreSQL dropped connection, concurrent write lock timeouts.","solutions":["Check disk space and filesystem permissions on the DB file.","Verify DB health (`cscli db doctor`) and connectivity.","Enable SQLite WAL mode.","Re-run the pull; the next cycle will rewrite the timestamp (worst case the blocklist is re-pulled fully)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check disk space and DB writability before pulls\ncscli db doctor","typeGuard":null,"tryCatchPattern":"if err := a.dbClient.SetConfigItem(ctx, name, ts); err != nil {\n    log.Warnf(\"could not persist last_pull timestamp: %v\", err)\n    // worst case: blocklist is re-pulled next cycle\n}","preventionTips":["Monitor free disk space where the DB lives.","Ensure the crowdsec user can write to the DB file/mount.","Enable SQLite WAL mode."],"tags":["database","config-item","write","blocklist"],"backgroundTag":"database-write-failed","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}