canopy-network/canopy · error

write height file: %w

Error message

write height file: %w

What it means

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.

Source

Thrown at store/store.go:791

		// may not be durable on disk at checkpoint time)
		s.mu.Lock()
		version = s.Version()
		if err = s.db.Flush(); err != nil {
			s.mu.Unlock()
			err = fmt.Errorf("flush before checkpoint: %w", err)
			return
		}
		s.mu.Unlock()
		// perform the backup using pebble's checkpointing mechanism which creates a
		// consistent snapshot of the database at the specified directory
		if err = s.db.Checkpoint(tempBackupDir); err != nil {
			err = fmt.Errorf("checkpoint creation: %w", err)
			return
		}
		// write the current height to a separate file
		heightFile := filepath.Join(tempBackupDir, "height.txt")
		if err = os.WriteFile(heightFile, fmt.Appendf(nil, "%d", version), 0644); err != nil {
			err = fmt.Errorf("write height file: %w", err)
			return
		}
		if err = os.Rename(backupDir, prevBackupDir); err != nil && !os.IsNotExist(err) {
			err = fmt.Errorf("rotate backup: %w", err)
			return
		}
		// promote: atomically move the temp backup into the active slot
		if err = os.Rename(tempBackupDir, backupDir); err != nil {
			err = fmt.Errorf("finalize backup: %w", err)
			return
		}
		backupDuration := time.Since(start)
		// log results
		s.log.Infof("backup completed at height [%d] in %s", version, backupDuration)
		// update metrics
		s.metrics.UpdateStoreJobMetrics(0, 0, backupDuration)
	}()
}

View on GitHub (pinned to ee8197d91d)

Solutions

  1. Check disk space and directory permissions for tempBackupDir.
  2. Inspect the wrapped OS error (e.g. ENOSPC, EACCES) to identify the filesystem issue.
  3. Retry the backup after freeing space or fixing permissions; the checkpoint step succeeded so only the height write needs redoing.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at store/store.go:791 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of canopy-network/canopy@ee8197d91d (2026-09-06). Data as JSON: /api/errors/37d93799a9063df3. Report an issue: GitHub.