juicedata/juicefs · error
Compress block key %s: %s
Error message
Compress block key %s: %s
What it means
During upload, the cached store compresses each block with the configured compressor. If Compress returns an error, upload aborts and wraps it as "Compress block key %s: %s", identifying the block key and the underlying compression failure. The block buffer is released either way, so the upload does not retry compression here.
Source
Thrown at pkg/chunk/cached_store.go:363
sync := s != nil
blen := len(block.Data)
bufSize := store.compressor.CompressBound(blen)
var buf *Page
if bufSize > blen {
buf = NewOffPage(bufSize)
} else {
buf = block
buf.Acquire()
}
defer buf.Release()
if sync && (blen < store.conf.BlockSize || store.conf.CacheLargeWrite) {
// block will be freed after written into disk
store.bcache.cache(key, block, false, false)
}
n, err := store.compressor.Compress(buf.Data, block.Data)
block.Release()
if err != nil {
return fmt.Errorf("Compress block key %s: %s", key, err)
}
buf.Data = buf.Data[:n]
try, max := 0, 3
if sync {
max = store.conf.MaxRetries + 1
}
for ; try < max; try++ {
time.Sleep(time.Second * time.Duration(try*try))
if s != nil && s.uploadError != nil {
err = fmt.Errorf("(cancelled) upload block %s: %s (after %d tries)", key, err, try)
break
}
if err = store.put(ctx, key, buf); err == nil {
break
}
logger.Debugf("Upload %s: %s (try %d)", key, err, try+1)
}View on GitHub (pinned to c9a67b23e8)
Solutions
- Check the wrapped inner error (%s) to identify the root cause (corrupt data vs compressor failure).
- Switch to a different --compress setting (e.g. 'lz4' or 'none') in the volume format and re-test the workload.
- Verify staging/cache disk integrity (fsck, SMART) — corruption is a common root cause; re-upload the affected block from source data.
- Upgrade JuiceFS: compressor bugs have been fixed in past releases; ensure client versions are consistent.
Example fix
// before juicefs format --compress zstd sqlite3://test.db myjfs // after (fallback to widely-supported algorithm) juicefs format --compress lz4 sqlite3://test.db myjfs
Defensive patterns
Strategy: try-catch
Try / catch
if err := storeUpload(ctx, key, buf); err != nil {
if strings.HasPrefix(err.Error(), "Compress block key") {
// check wrapped cause; consider re-reading block or changing --compress
}
} Prevention
- Choose a stable, well-supported compressor in volume format
- Monitor disk health — corruption is a common trigger
- Keep client versions consistent across the cluster
When it happens
Trigger: A block fails to compress — typically corrupt or invalid input data for the configured compressor (e.g. zstd/lz4 failing on malformed input), a compressor misconfiguration, or a broken compressor implementation returning an unexpected result.
Common situations: --compress option set to an algorithm whose library fails on some data; corrupted staging/cache files on a failing disk; version mismatch where a compressor registered under a name behaves differently.
Related errors
- ceph: can't put empty file
- read wrong data: expected %x, got %x
- (cancelled) upload block %s: %s (after %d tries)
- (max tries) upload block %s: %s (after %d tries)
- buffer too short: %d < %d
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/ceed61b359d3695c.
Report an issue: GitHub.