@@ -17,7 +17,9 @@ import (
17
17
"github.com/cockroachdb/cockroach/pkg/roachpb"
18
18
"github.com/cockroachdb/cockroach/pkg/security/username"
19
19
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
20
+ "github.com/cockroachdb/cockroach/pkg/storage/storageconfig"
20
21
"github.com/cockroachdb/cockroach/pkg/util/envutil"
22
+ "github.com/cockroachdb/cockroach/pkg/util/log"
21
23
"github.com/cockroachdb/cockroach/pkg/util/mon"
22
24
"github.com/cockroachdb/cockroach/pkg/util/retry"
23
25
)
@@ -904,19 +906,25 @@ type TempStorageConfig struct {
904
906
// InMemory specifies whether the temporary storage will remain
905
907
// in-memory or occupy a temporary subdirectory on-disk.
906
908
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 .
909
911
Path string
910
912
// Mon will be used by the temp storage to register all its capacity requests.
911
913
// It can be used to limit the disk or memory that temp storage is allowed to
912
914
// use. If InMemory is set, than this has to be a memory monitor; otherwise it
913
915
// has to be a disk monitor.
914
916
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
917
920
// Settings stores the cluster.Settings this TempStoreConfig will use. Must
918
921
// not be nil.
919
922
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
920
928
}
921
929
922
930
// ExternalIODirConfig describes various configuration options pertaining
@@ -948,32 +956,29 @@ type ExternalIODirConfig struct {
948
956
EnableNonAdminImplicitAndArbitraryOutbound bool
949
957
}
950
958
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
-
965
959
// InheritTempStorageConfig creates a new TempStorageConfig using the
966
960
// configuration of the given TempStorageConfig. It assumes the given
967
961
// TempStorageConfig has been fully initialized.
968
962
func InheritTempStorageConfig (
969
963
ctx context.Context , st * cluster.Settings , parentConfig TempStorageConfig ,
970
964
) 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 )
972
966
}
973
967
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 ,
976
978
) TempStorageConfig {
979
+ if inMemory != (path == "" ) {
980
+ log .Dev .Fatalf (ctx , "inMemory (%t) must be true iff path is empty (%q)" , inMemory , path )
981
+ }
977
982
var monitorName mon.Name
978
983
if inMemory {
979
984
monitorName = mon .MakeName ("in-mem temp storage" )
@@ -988,9 +993,11 @@ func newTempStorageConfig(
988
993
})
989
994
monitor .Start (ctx , nil /* pool */ , mon .NewStandaloneBudget (maxSizeBytes ))
990
995
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 ,
995
1002
}
996
1003
}
0 commit comments