@@ -127,7 +127,9 @@ var (
127
127
)
128
128
129
129
const (
130
- indexUsageGCDuration = 30 * time .Minute
130
+ indexUsageGCDuration = 30 * time .Minute
131
+ systemSessionPoolSize = 200
132
+ dxfSessionPoolSize = 100
131
133
)
132
134
133
135
// NewMockDomain is only used for test
@@ -162,6 +164,7 @@ type Domain struct {
162
164
// Otherwise, the session will be leaked. Because there is a strong reference from the domain to the session.
163
165
// Deprecated: Use `advancedSysSessionPool` instead.
164
166
sysSessionPool util.DestroyableSessionPool
167
+ dxfSessionPool util.DestroyableSessionPool
165
168
exit chan struct {}
166
169
// `etcdClient` must be used when keyspace is not set, or when the logic to each etcd path needs to be separated by keyspace.
167
170
etcdClient * clientv3.Client
@@ -508,6 +511,7 @@ func (do *Domain) Close() {
508
511
}
509
512
510
513
do .sysSessionPool .Close ()
514
+ do .dxfSessionPool .Close ()
511
515
do .advancedSysSessionPool .Close ()
512
516
variable .UnregisterStatistics (do .BindingHandle ())
513
517
if do .onClose != nil {
@@ -546,31 +550,11 @@ func NewDomainWithEtcdClient(
546
550
etcdClient * clientv3.Client ,
547
551
) * Domain {
548
552
intest .Assert (schemaLease > 0 , "schema lease should be a positive duration" )
549
- capacity := 200 // capacity of the sysSessionPool size
550
553
do := & Domain {
551
- store : store ,
552
- exit : make (chan struct {}),
553
- sysSessionPool : util .NewSessionPool (
554
- capacity , factory ,
555
- func (r pools.Resource ) {
556
- _ , ok := r .(sessionctx.Context )
557
- intest .Assert (ok )
558
- infosync .StoreInternalSession (r )
559
- },
560
- func (r pools.Resource ) {
561
- sctx , ok := r .(sessionctx.Context )
562
- intest .Assert (ok )
563
- intest .AssertFunc (func () bool {
564
- txn , _ := sctx .Txn (false )
565
- return txn == nil || ! txn .Valid ()
566
- })
567
- infosync .DeleteInternalSession (r )
568
- },
569
- func (r pools.Resource ) {
570
- intest .Assert (r != nil )
571
- infosync .DeleteInternalSession (r )
572
- },
573
- ),
554
+ store : store ,
555
+ exit : make (chan struct {}),
556
+ sysSessionPool : createInternelSessionPool (systemSessionPoolSize , factory ),
557
+ dxfSessionPool : createInternelSessionPool (dxfSessionPoolSize , factory ),
574
558
statsLease : statsLease ,
575
559
schemaLease : schemaLease ,
576
560
slowQuery : newTopNSlowQueries (config .GetGlobalConfig ().InMemSlowQueryTopNNum , time .Hour * 24 * 7 , config .GetGlobalConfig ().InMemSlowQueryRecentNum ),
@@ -579,7 +563,7 @@ func NewDomainWithEtcdClient(
579
563
crossKSSessFactoryGetter : crossKSSessFactoryGetter ,
580
564
}
581
565
582
- do .advancedSysSessionPool = syssession .NewAdvancedSessionPool (capacity , func () (syssession.SessionContext , error ) {
566
+ do .advancedSysSessionPool = syssession .NewAdvancedSessionPool (systemSessionPoolSize , func () (syssession.SessionContext , error ) {
583
567
r , err := factory ()
584
568
if err != nil {
585
569
return nil , err
@@ -614,6 +598,30 @@ func NewDomainWithEtcdClient(
614
598
return do
615
599
}
616
600
601
+ func createInternelSessionPool (capacity int , factory pools.Factory ) util.DestroyableSessionPool {
602
+ return util .NewSessionPool (
603
+ capacity , factory ,
604
+ func (r pools.Resource ) {
605
+ _ , ok := r .(sessionctx.Context )
606
+ intest .Assert (ok )
607
+ infosync .StoreInternalSession (r )
608
+ },
609
+ func (r pools.Resource ) {
610
+ sctx , ok := r .(sessionctx.Context )
611
+ intest .Assert (ok )
612
+ intest .AssertFunc (func () bool {
613
+ txn , _ := sctx .Txn (false )
614
+ return txn == nil || ! txn .Valid ()
615
+ })
616
+ infosync .DeleteInternalSession (r )
617
+ },
618
+ func (r pools.Resource ) {
619
+ intest .Assert (r != nil )
620
+ infosync .DeleteInternalSession (r )
621
+ },
622
+ )
623
+ }
624
+
617
625
const serverIDForStandalone = 1 // serverID for standalone deployment.
618
626
619
627
// Init initializes a domain. after return, session can be used to do DMLs but not
@@ -1042,7 +1050,7 @@ func (do *Domain) InitDistTaskLoop() error {
1042
1050
}
1043
1051
})
1044
1052
1045
- taskManager := storage .NewTaskManager (do .sysSessionPool )
1053
+ taskManager := storage .NewTaskManager (do .dxfSessionPool )
1046
1054
storage .SetTaskManager (taskManager )
1047
1055
1048
1056
if keyspace .IsRunningOnUser () {
0 commit comments