Skip to content

Commit ed318e1

Browse files
committed
sharedcache: implement minimal version of metadata persistence
This commit implements an approach to persisting metadata thought of by Radu. The metadata being persisted is the mapping from <filenum, logical block offset> to the index of the cache block at which the data is located on disk. The basic approach is to write changes to the metadata, plus metadata pointed at by a ptr based on a sequence number, to a circular log that can be replayed at server start time. As of this commit, metadata persistence is neither performant nor safe in the presence of crashes or certain errors happening at file write time. We need to also implement the working set idea thought of by Radu, but this commit is large enough without that.
1 parent e7aa90f commit ed318e1

6 files changed

Lines changed: 381 additions & 62 deletions

File tree

objstorage/objstorageprovider/provider.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ type Settings struct {
106106
// 2*runtime.GOMAXPROCS is used as the shard count.
107107
CacheShardCount int
108108

109+
// If true, metadata on the mapping from logical block indexes to cache block indexes
110+
// is persisted, implying that the contents in the cache are usable after a server
111+
// restart.
112+
PersistMetadata bool
113+
109114
// TODO(radu): allow the cache to live on another FS/location (e.g. to use
110115
// instance-local SSD).
111116
}

objstorage/objstorageprovider/shared.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ func (p *provider) sharedInit() error {
8080
numShards = 2 * runtime.GOMAXPROCS(0)
8181
}
8282

83-
p.shared.cache, err = sharedcache.Open(p.st.FS, p.st.FSDirName, blockSize, p.st.Shared.CacheSizeBytes, numShards)
83+
p.shared.cache, err = sharedcache.Open(
84+
p.st.FS, p.st.FSDirName, blockSize, p.st.Shared.CacheSizeBytes, numShards, p.st.Shared.PersistMetadata)
8485
if err != nil {
8586
return errors.Wrapf(err, "pebble: could not open shared object cache")
8687
}

0 commit comments

Comments
 (0)