{"record":{"id":"37d93799a9063df3","repo":"canopy-network/canopy","slug":"write-height-file-w","errorCode":null,"errorMessage":"write height file: %w","messagePattern":"write height file: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"store/store.go","lineNumber":791,"sourceCode":"\t\t// may not be durable on disk at checkpoint time)\n\t\ts.mu.Lock()\n\t\tversion = s.Version()\n\t\tif err = s.db.Flush(); err != nil {\n\t\t\ts.mu.Unlock()\n\t\t\terr = fmt.Errorf(\"flush before checkpoint: %w\", err)\n\t\t\treturn\n\t\t}\n\t\ts.mu.Unlock()\n\t\t// perform the backup using pebble's checkpointing mechanism which creates a\n\t\t// consistent snapshot of the database at the specified directory\n\t\tif err = s.db.Checkpoint(tempBackupDir); err != nil {\n\t\t\terr = fmt.Errorf(\"checkpoint creation: %w\", err)\n\t\t\treturn\n\t\t}\n\t\t// write the current height to a separate file\n\t\theightFile := filepath.Join(tempBackupDir, \"height.txt\")\n\t\tif err = os.WriteFile(heightFile, fmt.Appendf(nil, \"%d\", version), 0644); err != nil {\n\t\t\terr = fmt.Errorf(\"write height file: %w\", err)\n\t\t\treturn\n\t\t}\n\t\tif err = os.Rename(backupDir, prevBackupDir); err != nil && !os.IsNotExist(err) {\n\t\t\terr = fmt.Errorf(\"rotate backup: %w\", err)\n\t\t\treturn\n\t\t}\n\t\t// promote: atomically move the temp backup into the active slot\n\t\tif err = os.Rename(tempBackupDir, backupDir); err != nil {\n\t\t\terr = fmt.Errorf(\"finalize backup: %w\", err)\n\t\t\treturn\n\t\t}\n\t\tbackupDuration := time.Since(start)\n\t\t// log results\n\t\ts.log.Infof(\"backup completed at height [%d] in %s\", version, backupDuration)\n\t\t// update metrics\n\t\ts.metrics.UpdateStoreJobMetrics(0, 0, backupDuration)\n\t}()\n}","sourceCodeStart":773,"sourceCodeEnd":809,"githubUrl":"https://github.com/canopy-network/canopy/blob/ee8197d91dd410f6592cb650a94c925ee6dc8bad/store/store.go#L773-L809","documentation":"Wrapped failure (fmt.Errorf with %w) around os.WriteFile when persisting the current store height to height.txt inside tempBackupDir after a successful pebble checkpoint. Without this file the backup cannot record which height it corresponds to, so the backup attempt is aborted.","triggerScenarios":"Thrown at store/store.go:791 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and directory permissions for tempBackupDir.","Inspect the wrapped OS error (e.g. ENOSPC, EACCES) to identify the filesystem issue.","Retry the backup after freeing space or fixing permissions; the checkpoint step succeeded so only the height write needs redoing."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ee8197d91dd410f6592cb650a94c925ee6dc8bad","analyzedAt":"2026-09-06T09:30:15.973Z","contentChangedAt":"2026-09-06T09:30:15.973Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}