Skip to content

Commit 64cae35

Browse files
authored
Clean up legacy CDC logic (#11471)
Currently, there are two levels of CDC implementation. One is within the pebble cache, acting underneath the storage layer to act as a more efficient storage system, the other is remote cache application layer logic in the CAS, built to be visible through the remote cache APIs. Keeping this old implementation around has caused confusion, since the flags are so similar. The new implementation has been adjusted so that it adheres to: - bazelbuild/remote-apis@de5501d - bazelbuild/remote-apis@080cf12 - bazelbuild/remote-apis@9ef19c6 Moving the CDC logic from pebble_cache -> CAS/ByteStream layer allows us to make it distributed, so that if large files share chunks, we only need to store the chunks once. It also means that clients can only request specific chunks, rather than being required to also tell the server which blob they are trying to reconstruct.
1 parent 927c96e commit 64cae35

13 files changed

Lines changed: 357 additions & 1280 deletions

File tree

enterprise/server/backends/cache_config/cache_config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ type PebbleCacheConfig struct {
6161
AtimeBufferSize *int `yaml:"atime_buffer_size"`
6262
MinEvictionAge *time.Duration `yaml:"min_eviction_age"`
6363
MinBytesAutoZstdCompression *int64 `yaml:"min_bytes_auto_zstd_compression"`
64-
AverageChunkSizeBytes int `yaml:"average_chunk_size_bytes"`
6564
ClearCacheOnStartup bool `yaml:"clear_cache_on_startup"`
6665
ActiveKeyVersion *int64 `yaml:"active_key_version"`
6766
GCSConfig GCSConfig `yaml:"gcs"`

enterprise/server/backends/metacache/metacache.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ func (c *Cache) writerForRecord(ctx context.Context, fileRecord *sgpb.FileRecord
386386
}
387387
}
388388

389-
func (c *Cache) newWrappedWriter(ctx context.Context, fileRecord *sgpb.FileRecord, sizeHint int64, fileType sgpb.FileMetadata_FileType, fn writeMetadataFn) (interfaces.CommittedWriteCloser, error) {
389+
func (c *Cache) newWrappedWriter(ctx context.Context, fileRecord *sgpb.FileRecord, sizeHint int64, fn writeMetadataFn) (interfaces.CommittedWriteCloser, error) {
390390
wcm, err := c.writerForRecord(ctx, fileRecord, sizeHint)
391391
if err != nil {
392392
return nil, err
@@ -403,7 +403,6 @@ func (c *Cache) newWrappedWriter(ctx context.Context, fileRecord *sgpb.FileRecor
403403
StoredSizeBytes: bytesWritten,
404404
LastAccessUsec: now,
405405
LastModifyUsec: now,
406-
FileType: fileType,
407406
}
408407
if bytesWritten == 0 {
409408
log.Infof("Rejecting zero-length write. Metadata: %+v", md)
@@ -478,7 +477,7 @@ func (c *Cache) writer(ctx context.Context, r *rspb.ResourceName, sizeHint int64
478477
return nil, err
479478
}
480479

481-
wc, err := c.newWrappedWriter(ctx, fileRecord, sizeHint, sgpb.FileMetadata_COMPLETE_FILE_TYPE, fn)
480+
wc, err := c.newWrappedWriter(ctx, fileRecord, sizeHint, fn)
482481
if err != nil {
483482
return nil, err
484483
}
@@ -704,11 +703,9 @@ func (c *Cache) Delete(ctx context.Context, r *rspb.ResourceName) (resultErr err
704703
}
705704

706705
func (c *Cache) reader(ctx context.Context, md *sgpb.FileMetadata, r *rspb.ResourceName, uncompressedOffset, uncompressedLimit int64) (io.ReadCloser, error) {
707-
// If this object was not chunked, and is somehow stored as a zero-
708-
// length file, pretend it does not exist.
709-
storageMetadata := md.GetStorageMetadata()
710-
711-
if chunkedMD := storageMetadata.GetChunkedMetadata(); chunkedMD == nil && md.GetStoredSizeBytes() == 0 {
706+
// If this object is somehow stored as a zero-length file, pretend it
707+
// does not exist.
708+
if md.GetStoredSizeBytes() == 0 {
712709
log.CtxInfof(ctx, "Ignoring zero-length file. md: %+v, resource: %v", md, r)
713710
return nil, status.NotFoundError("object not found (zero-length)")
714711
}
@@ -769,9 +766,7 @@ func (c *Cache) reader(ctx context.Context, md *sgpb.FileMetadata, r *rspb.Resou
769766
}
770767
reader = d
771768
}
772-
if shouldDecompress && storageMetadata.GetChunkedMetadata() == nil {
773-
// We don't need to decompress the chunked reader's content since
774-
// it already returns decompressed content from its children.
769+
if shouldDecompress {
775770
dr, err := compression.NewZstdDecompressingReader(reader)
776771
if err != nil {
777772
return nil, err

enterprise/server/backends/metacache/metacache_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ func getCrypterEnv(t *testing.T) (*testenv.TestEnv, string) {
256256
func TestEncryption(t *testing.T) {
257257
testCases := []struct {
258258
desc string
259-
averageChunkSizeBytes int
260259
maxInlineFileSizeBytes int64
261260
digestSize int64
262261
}{

enterprise/server/backends/migration_cache/migration_cache.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ func pebbleCacheFromConfig(env environment.Env, cfg *cache_config.PebbleCacheCon
195195
AtimeUpdateThreshold: cfg.AtimeUpdateThreshold,
196196
AtimeBufferSize: cfg.AtimeBufferSize,
197197
MinEvictionAge: cfg.MinEvictionAge,
198-
AverageChunkSizeBytes: cfg.AverageChunkSizeBytes,
199198
ClearCacheOnStartup: cfg.ClearCacheOnStartup,
200199
ActiveKeyVersion: cfg.ActiveKeyVersion,
201200
GCSBucket: cfg.GCSConfig.Bucket,

enterprise/server/backends/pebble_cache/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ go_library(
2020
"//server/interfaces",
2121
"//server/metrics",
2222
"//server/real_environment",
23-
"//server/remote_cache/chunking",
2423
"//server/remote_cache/digest",
2524
"//server/util/alert",
2625
"//server/util/approxlru",
@@ -52,7 +51,6 @@ go_test(
5251
name = "pebble_cache_test",
5352
size = "medium",
5453
srcs = ["pebble_cache_test.go"],
55-
shard_count = 2,
5654
deps = [
5755
":pebble_cache",
5856
"//enterprise/server/backends/kms",

0 commit comments

Comments
 (0)