diff --git a/pkg/client/clientpool.go b/pkg/client/clientpool.go index b3143ef2..b8aaa70b 100644 --- a/pkg/client/clientpool.go +++ b/pkg/client/clientpool.go @@ -122,13 +122,19 @@ func (p *ClientPool) Close() { } func (p *ClientPool) Init() error { + i := p.getActiveConnIdx() + if i == -1 { + return fmt.Errorf("no available session.") + } if p.postStart != nil && p.postStart.Commands != nil { - if i := p.getActiveConnIdx(); i != -1 { - if err := p.exec(i, *p.postStart.Commands); err != nil { - return err - } + if err := p.exec(i, *p.postStart.Commands); err != nil { + return err } } + // pre-check for use space statement + if err := p.exec(i, fmt.Sprintf("USE `%s`;", p.space)); err != nil { + return err + } for i := 0; i < p.concurrency; i++ { go func(i int) {