kopia/kopia · error
new map
Error message
new map
What it means
NewDirRewriter failed to create the bigmap.Map used as the rewriter's deduplication cache, so the DirRewriter cannot be constructed. bigmap backs the memoization that avoids reprocessing identical directory entries across snapshots.
Solutions
- Check that the context passed to NewDirRewriter is not already canceled and the repository writer is open and healthy.
- Inspect the inner bigmap error; ensure the process has adequate memory for the cache.
- Retry after fixing repository connectivity; NewDirRewriter has no side effects on existing data, so retry is safe.
- Report to Kopia if bigmap.NewMap fails on a healthy repository — this indicates an internal bug.
Example fix
// before rw, err := snapshotfs.NewDirRewriter(canceledCtx, rep, opts) // ctx already canceled // after ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute) defer cancel() rw, err := snapshotfs.NewDirRewriter(ctx, rep, opts)
Defensive patterns
Strategy: validation
Validate before calling
if rep == nil { return errors.New("rep must be a non-nil open RepositoryWriter") }
if err := ctx.Err(); err != nil { return err } Type guard
func canCreateRewriter(ctx context.Context, rep repo.RepositoryWriter) bool {
return ctx.Err() == nil && rep != nil
} Try / catch
rw, err := snapshotfs.NewDirRewriter(ctx, rep, opts)
if err != nil {
return fmt.Errorf("creating dir rewriter: %w", err)
}
defer rw.Close(ctx) Prevention
- Pass a live, uncanceled context to NewDirRewriter.
- Always Close the rewriter to release the workshare pool and cache.
- Ensure adequate memory for the bigmap cache on large snapshot sets.
- Only construct the rewriter with an open RepositoryWriter.
When it happens
Trigger: bigmap.NewMap(ctx) returns an error during NewDirRewriter — e.g. failures initializing in-memory/map storage or its underlying repository structures for the shared cache.
Common situations: Calling NewDirRewriter with a closed or unhealthy repository writer, context already canceled, resource exhaustion (memory limits), or an internal bigmap initialization bug in unusual environments.
Related errors
- error setting up read manager caches
- unable to create index blob cache
- unable to initialize content cache
- unable to initialize list cache
- unable to initialize metadata cache
AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07).
Data as JSON: /api/errors/7b77db05711d92df.
Report an issue: GitHub.
Appendix: source
Thrown at snapshot/snapshotfs/dir_rewriter.go:337
//
//nolint:revive
func RewriteRemove(ctx context.Context, parentPath string, entry *snapshot.DirEntry, err error) (*snapshot.DirEntry, error) {
return nil, nil
}
// NewDirRewriter creates a new directory rewriter.
func NewDirRewriter(ctx context.Context, rep repo.RepositoryWriter, opts DirRewriterOptions) (*DirRewriter, error) {
if opts.Parallel == 0 {
opts.Parallel = runtime.NumCPU()
}
if opts.OnDirectoryReadFailure == nil {
opts.OnDirectoryReadFailure = RewriteFail
}
cache, err := bigmap.NewMap(ctx)
if err != nil {
return nil, errors.Wrap(err, "new map")
}
return &DirRewriter{
ws: workshare.NewPool[*dirRewriterRequest](opts.Parallel - 1),
opts: opts,
rep: rep,
cache: cache,
}, nil
}
View on GitHub (pinned to 82495e54b5)