@@ -139,14 +139,22 @@ func newGCStateManagerForTest(t testing.TB, opt newGCStateManagerForTestOptions)
139139 err = keyspaceManager .Bootstrap ()
140140 re .NoError (err )
141141
142- // keyspaceID 0 exists automatically after bootstrapping.
142+ // The bootstrap keyspace (DefaultKeyspaceID or SystemKeyspaceID) exists automatically after bootstrapping.
143143 if opt .specifyInitialKeyspaces == nil {
144+ // In NextGen, all keyspaces should use keyspace_level GC
145+ // In Classic, we can have different GC management types
146+ var ks1Config map [string ]string
147+ if kerneltype .IsNextGen () {
148+ ks1Config = map [string ]string {"gc_management_type" : "keyspace_level" }
149+ } else {
150+ ks1Config = map [string ]string {"gc_management_type" : "unified" }
151+ }
144152 id := new (uint32 )
145153 * id = 1
146154 ks1 , err := keyspaceManager .CreateKeyspaceByID (& keyspace.CreateKeyspaceByIDRequest {
147155 ID : id ,
148156 Name : "ks1" ,
149- Config : map [ string ] string { "gc_management_type" : "unified" } ,
157+ Config : ks1Config ,
150158 CreateTime : time .Now ().Unix (),
151159 })
152160 re .NoError (err )
@@ -196,10 +204,21 @@ func newGCStateManagerForTest(t testing.TB, opt newGCStateManagerForTestOptions)
196204func (s * gcStateManagerTestSuite ) SetupTest () {
197205 s .storage , s .provider , s .manager , s .clean , s .cancel = newGCStateManagerForTest (s .T (), newGCStateManagerForTestOptions {})
198206
199- s .keyspacePresets .all = []uint32 {constant .NullKeyspaceID , 0 , 1 , 2 , 3 }
200- s .keyspacePresets .manageable = []uint32 {constant .NullKeyspaceID , 2 }
201- s .keyspacePresets .unmanageable = []uint32 {0 , 1 , 3 }
202- s .keyspacePresets .unifiedGC = []uint32 {constant .NullKeyspaceID , 0 , 1 , 3 }
207+ bootstrapKeyspaceID := keyspace .GetBootstrapKeyspaceID ()
208+ s .keyspacePresets .all = []uint32 {constant .NullKeyspaceID , bootstrapKeyspaceID , 1 , 2 , 3 }
209+
210+ // In NextGen builds, bootstrapKeyspaceID is SystemKeyspaceID (0xFFFFFE) with KeyspaceLevelGC config, so it's manageable.
211+ // In Classic builds, bootstrapKeyspaceID is DefaultKeyspaceID (0) without KeyspaceLevelGC config, so it's unmanageable.
212+ if kerneltype .IsNextGen () {
213+ // NextGen: all keyspaces default to KeyspaceLevelGC
214+ s .keyspacePresets .manageable = []uint32 {constant .NullKeyspaceID , bootstrapKeyspaceID , 1 , 2 , 3 }
215+ s .keyspacePresets .unmanageable = []uint32 {}
216+ s .keyspacePresets .unifiedGC = []uint32 {} // NextGen has no unified GC
217+ } else {
218+ s .keyspacePresets .manageable = []uint32 {constant .NullKeyspaceID , 2 }
219+ s .keyspacePresets .unmanageable = []uint32 {bootstrapKeyspaceID , 1 , 3 }
220+ s .keyspacePresets .unifiedGC = []uint32 {constant .NullKeyspaceID , bootstrapKeyspaceID , 1 , 3 }
221+ }
203222 s .keyspacePresets .notExisting = []uint32 {5 , 0xffffff }
204223 s .keyspacePresets .nullSynonyms = []uint32 {constant .NullKeyspaceID , 0x1000000 , 0xfffffffe }
205224}
@@ -1883,8 +1902,16 @@ func (s *gcStateManagerTestSuite) TestGetAllKeyspacesMaxTxnSafePoint() {
18831902 })
18841903 re .NoError (err )
18851904 re .Equal (uint64 (len (s .keyspacePresets .manageable )), txnSafePoint )
1886- re .Equal ("ks2" , keyspaceName )
1887- re .Equal (uint32 (2 ), keyspaceID )
1905+
1906+ // In NextGen, all keyspaces are manageable, so the max should be ks3
1907+ // In Classic, only certain keyspaces are manageable, so the max should be ks2
1908+ if kerneltype .IsNextGen () {
1909+ re .Equal ("ks3" , keyspaceName )
1910+ re .Equal (uint32 (3 ), keyspaceID )
1911+ } else {
1912+ re .Equal ("ks2" , keyspaceName )
1913+ re .Equal (uint32 (2 ), keyspaceID )
1914+ }
18881915}
18891916
18901917func (s * gcStateManagerTestSuite ) TestWeakenedConstraints () {
0 commit comments