@@ -17,7 +17,9 @@ import (
1717 "github.com/cockroachdb/cockroach/pkg/roachpb"
1818 "github.com/cockroachdb/cockroach/pkg/security/username"
1919 "github.com/cockroachdb/cockroach/pkg/settings/cluster"
20+ "github.com/cockroachdb/cockroach/pkg/storage/storageconfig"
2021 "github.com/cockroachdb/cockroach/pkg/util/envutil"
22+ "github.com/cockroachdb/cockroach/pkg/util/log"
2123 "github.com/cockroachdb/cockroach/pkg/util/mon"
2224 "github.com/cockroachdb/cockroach/pkg/util/retry"
2325)
@@ -904,19 +906,25 @@ type TempStorageConfig struct {
904906 // InMemory specifies whether the temporary storage will remain
905907 // in-memory or occupy a temporary subdirectory on-disk.
906908 InMemory bool
907- // Path is the filepath of the temporary subdirectory created for
908- // the temp storage .
909+ // Path is the filepath of the temporary subdirectory created for the temp
910+ // storage. Empty if InMemory is true .
909911 Path string
910912 // Mon will be used by the temp storage to register all its capacity requests.
911913 // It can be used to limit the disk or memory that temp storage is allowed to
912914 // use. If InMemory is set, than this has to be a memory monitor; otherwise it
913915 // has to be a disk monitor.
914916 Mon * mon.BytesMonitor
915- // Spec stores the StoreSpec this TempStorageConfig will use.
916- Spec StoreSpec
917+ // Encryption is set if encryption is enabled. We use the same encryption
918+ // options as the store we chose for temp storage.
919+ Encryption * storageconfig.EncryptionOptions
917920 // Settings stores the cluster.Settings this TempStoreConfig will use. Must
918921 // not be nil.
919922 Settings * cluster.Settings
923+ // If set, TempDirsRecordPath is the path to a temp-dirs-record.txt file in
924+ // one of the stores (see server.TempDirsRecordFilename). Used when we create
925+ // a new temporary storage directory for a new shared-process tenant. Empty if
926+ // InMemory is false.
927+ TempDirsRecordPath string
920928}
921929
922930// ExternalIODirConfig describes various configuration options pertaining
@@ -948,32 +956,29 @@ type ExternalIODirConfig struct {
948956 EnableNonAdminImplicitAndArbitraryOutbound bool
949957}
950958
951- // TempStorageConfigFromEnv creates a TempStorageConfig.
952- // If parentDir is not specified and the specified store is in-memory,
953- // then the temp storage will also be in-memory.
954- func TempStorageConfigFromEnv (
955- ctx context.Context ,
956- st * cluster.Settings ,
957- useStore StoreSpec ,
958- parentDir string ,
959- maxSizeBytes int64 ,
960- ) TempStorageConfig {
961- inMem := parentDir == "" && useStore .InMemory
962- return newTempStorageConfig (ctx , st , inMem , useStore , maxSizeBytes )
963- }
964-
965959// InheritTempStorageConfig creates a new TempStorageConfig using the
966960// configuration of the given TempStorageConfig. It assumes the given
967961// TempStorageConfig has been fully initialized.
968962func InheritTempStorageConfig (
969963 ctx context.Context , st * cluster.Settings , parentConfig TempStorageConfig ,
970964) TempStorageConfig {
971- return newTempStorageConfig (ctx , st , parentConfig .InMemory , parentConfig .Spec , parentConfig .Mon .Limit ())
965+ return NewTempStorageConfig (ctx , st , parentConfig .InMemory , parentConfig .Path , parentConfig .Encryption , parentConfig . Mon .Limit (), parentConfig . TempDirsRecordPath )
972966}
973967
974- func newTempStorageConfig (
975- ctx context.Context , st * cluster.Settings , inMemory bool , useStore StoreSpec , maxSizeBytes int64 ,
968+ // NewTempStorageConfig creates a new TempStorageConfig.
969+ // The path should be empty iff inMemory is true.
970+ func NewTempStorageConfig (
971+ ctx context.Context ,
972+ st * cluster.Settings ,
973+ inMemory bool ,
974+ path string ,
975+ encryption * storageconfig.EncryptionOptions ,
976+ maxSizeBytes int64 ,
977+ tempDirsRecordPath string ,
976978) TempStorageConfig {
979+ if inMemory != (path == "" ) {
980+ log .Dev .Fatalf (ctx , "inMemory (%t) must be true iff path is empty (%q)" , inMemory , path )
981+ }
977982 var monitorName mon.Name
978983 if inMemory {
979984 monitorName = mon .MakeName ("in-mem temp storage" )
@@ -988,9 +993,11 @@ func newTempStorageConfig(
988993 })
989994 monitor .Start (ctx , nil /* pool */ , mon .NewStandaloneBudget (maxSizeBytes ))
990995 return TempStorageConfig {
991- InMemory : inMemory ,
992- Mon : monitor ,
993- Spec : useStore ,
994- Settings : st ,
996+ InMemory : inMemory ,
997+ Path : path ,
998+ Mon : monitor ,
999+ Encryption : encryption ,
1000+ Settings : st ,
1001+ TempDirsRecordPath : tempDirsRecordPath ,
9951002 }
9961003}
0 commit comments