{"record":{"id":"ceed61b359d3695c","repo":"juicedata/juicefs","slug":"compress-block-key-s-s","errorCode":null,"errorMessage":"Compress block key %s: %s","messagePattern":"Compress block key (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/cached_store.go","lineNumber":363,"sourceCode":"\tsync := s != nil\n\tblen := len(block.Data)\n\tbufSize := store.compressor.CompressBound(blen)\n\tvar buf *Page\n\tif bufSize > blen {\n\t\tbuf = NewOffPage(bufSize)\n\t} else {\n\t\tbuf = block\n\t\tbuf.Acquire()\n\t}\n\tdefer buf.Release()\n\tif sync && (blen < store.conf.BlockSize || store.conf.CacheLargeWrite) {\n\t\t// block will be freed after written into disk\n\t\tstore.bcache.cache(key, block, false, false)\n\t}\n\tn, err := store.compressor.Compress(buf.Data, block.Data)\n\tblock.Release()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Compress block key %s: %s\", key, err)\n\t}\n\tbuf.Data = buf.Data[:n]\n\n\ttry, max := 0, 3\n\tif sync {\n\t\tmax = store.conf.MaxRetries + 1\n\t}\n\tfor ; try < max; try++ {\n\t\ttime.Sleep(time.Second * time.Duration(try*try))\n\t\tif s != nil && s.uploadError != nil {\n\t\t\terr = fmt.Errorf(\"(cancelled) upload block %s: %s (after %d tries)\", key, err, try)\n\t\t\tbreak\n\t\t}\n\t\tif err = store.put(ctx, key, buf); err == nil {\n\t\t\tbreak\n\t\t}\n\t\tlogger.Debugf(\"Upload %s: %s (try %d)\", key, err, try+1)\n\t}","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/cached_store.go#L345-L381","documentation":"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.","triggerScenarios":"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.","commonSituations":"--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.","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."],"exampleFix":"// before\njuicefs format --compress zstd sqlite3://test.db myjfs\n// after (fallback to widely-supported algorithm)\njuicefs format --compress lz4 sqlite3://test.db myjfs","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := storeUpload(ctx, key, buf); err != nil {\n    if strings.HasPrefix(err.Error(), \"Compress block key\") {\n        // check wrapped cause; consider re-reading block or changing --compress\n    }\n}","preventionTips":["Choose a stable, well-supported compressor in volume format","Monitor disk health — corruption is a common trigger","Keep client versions consistent across the cluster"],"tags":["compression","upload","data-corruption"],"backgroundTag":"compression-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}