go-ora icon indicating copy to clipboard operation
go-ora copied to clipboard

driver doesn't support failover

Open luxiangqing opened this issue 3 years ago • 2 comments

the current connection is established on node 2. If the node is down, the connection cannot be automatically failover to node1, c client and jdbc can automatically failover

test database error: write tcp client_ip:50615->node2_ip:1521: wsasend: An established connection was aborted by the software in your host machine.

luxiangqing avatar Oct 22 '21 13:10 luxiangqing

My boss is considering using this driver because it doesn't support failover yet. Do you have any plan for this issue? If yes, please let me know. Thank you!

captain-corgi avatar Jul 18 '22 08:07 captain-corgi

I am also super interested in this. on production env we have running database with failover once my code migrated to production it couldnt handle/parse the long wired connection string. one guy from prod team help us by changing the connection string to one database to make it work for now.

najam-awan-db avatar Aug 16 '22 07:08 najam-awan-db

I will start working on this issue but the problem I don't have oracle RAC or nodes to test I think first place to start is this code in session.go

for loop {
	host = connOption.GetActiveServer(false)
	if host == nil {
		return errors.New("no available servers to connect to")
	}
	addr := host.networkAddr()
	if len(session.Context.ConnOption.UnixAddress) > 0 {
		session.conn, err = dialer.DialContext(ctx, "unix", session.Context.ConnOption.UnixAddress)
	} else {
		session.conn, err = dialer.DialContext(ctx, "tcp", addr)
	}

	if err != nil {
		connOption.Tracer.Printf("using: %s ..... [FAILED]", addr)
		host = connOption.GetActiveServer(true)
		if host == nil {
			break
		}
		continue
	}
	connOption.Tracer.Printf("using: %s ..... [SUCCEED]", addr)
	connected = true
	loop = false
}

the line

host = connOption.GetActiveServer(false)
if host == nil {
       return errors.New("no available servers to connect to")
}

if failover is active this line should always return a host by cycle hosts over and over is this correct?

sijms avatar Nov 23 '22 19:11 sijms

I add support for failover please test and write your feedback

sijms avatar Nov 24 '22 23:11 sijms

Problem is our oracle rack this is available only in prod and if its exploding in prod next release might take 1 or 2 weeks.

najam-awan-db avatar Nov 25 '22 11:11 najam-awan-db