sijms / go-ora

Pure go oracle client
MIT License
796 stars 177 forks source link

Interrupt a running operation #507

Closed rheilek closed 8 months ago

rheilek commented 8 months ago

Using context.WithCancel a call to the cancel func should interrupt the running operation (code snippet below).

ctx, cancel := context.WithCancel(context.Background())

go func () {
    fmt.Println(db.ExecContext(ctx, "begin for i in 1..120 loop dbms_lock.sleep(1); end loop; end;"))
}()

go func() {
    time.Sleep(1 * time.Second)
    cancel()
}()

To get it work i disable Urgent-Data-Transport (OOB) because sendOOB on windows is empty. Furthermore oracle-jdbc-driver and nodejs-thin-driver in my debug cases only (can) send marker packets.

The main challenge is the race conidtion between the running operation (read) and another concurrent read from BreakConnection. That's why i simplify the code with returning an error instead of reading the ORA-01013 packet.

rheilek commented 8 months ago

another PR, create dedicated branches...