Skip to content

Commit

Permalink
quick fix to check the hypothesis
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyamsinghal committed Dec 3, 2024
1 parent ee4cc05 commit b1ffdfa
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions yb-voyager/cmd/importData.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ func importData(importFileTasks []*ImportFileTask) {
if err != nil {
utils.ErrExit("Failed to initialize the target DB connection pool: %s", err)
}
defer tdb.CloseConnPool()

var adaptiveParallelismStarted bool
if tconf.EnableYBAdaptiveParallelism {
Expand Down
9 changes: 9 additions & 0 deletions yb-voyager/src/tgtdb/conn_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ func NewConnectionPool(params *ConnectionParams) *ConnectionPool {
return pool
}

func (pool *ConnectionPool) CloseConnectionPool() {
for i := 0; i < pool.params.NumConnections; i++ {
c := <-pool.idleConns
if c != nil {
c.Close(context.Background())
}
}
}

func (pool *ConnectionPool) GetNumConnections() int {
return pool.size
}
Expand Down
4 changes: 4 additions & 0 deletions yb-voyager/src/tgtdb/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ func (tdb *TargetOracleDB) InitConnPool() error {
return nil
}

func (tdb *TargetOracleDB) CloseConnPool() error {
return nil
}

func (tdb *TargetOracleDB) PrepareForStreaming() {}

func (tdb *TargetOracleDB) getConnectionUri(tconf *TargetConf) string {
Expand Down
5 changes: 5 additions & 0 deletions yb-voyager/src/tgtdb/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ func (pg *TargetPostgreSQL) InitConnPool() error {
return nil
}

func (pg *TargetPostgreSQL) CloseConnPool() error {
pg.connPool.CloseConnectionPool()
return nil
}

func (pg *TargetPostgreSQL) GetCallhomeTargetDBInfo() *callhome.TargetDBDetails {
totalCores, _ := fetchCores([]*TargetConf{pg.tconf})
return &callhome.TargetDBDetails{
Expand Down
1 change: 1 addition & 0 deletions yb-voyager/src/tgtdb/target_db_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type TargetDB interface {
Init() error
Finalize()
InitConnPool() error
CloseConnPool() error
PrepareForStreaming()
GetVersion() string
CreateVoyagerSchema() error
Expand Down
5 changes: 5 additions & 0 deletions yb-voyager/src/tgtdb/yugabytedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ func (yb *TargetYugabyteDB) InitConnPool() error {
return nil
}

func (yb *TargetYugabyteDB) CloseConnPool() error {
yb.connPool.CloseConnectionPool()
return nil
}

func (yb *TargetYugabyteDB) GetAllSchemaNamesRaw() ([]string, error) {
query := "SELECT schema_name FROM information_schema.schemata"
rows, err := yb.Query(query)
Expand Down

0 comments on commit b1ffdfa

Please sign in to comment.