sijms / go-ora

Pure go oracle client
MIT License
814 stars 178 forks source link

No data or expired data that is different from result in Dbeaver with same SQL returned #615

Open cloorc opened 1 week ago

cloorc commented 1 week ago

Oracle db:

Oracle Oracle Database 19c Enterprise Edition
Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

We are using gorm-oracle, which will import go-ora finally, to interact with Oracle database.

go-ora version in go.mod: github.com/sijms/go-ora/v2 v2.8.11.

For following SQL:

SELECT * FROM "t_key" WHERE "tenant_id" = :1 AND "app_id" = :2 AND "dispatching_key" = :3 AND "delete_flag" = :4 ORDER BY "t_key"."id"  FETCH NEXT :5 ROWS ONLY

We occasionally got nothing returned or wrong status in gorm.DB#First(). However, in Dbeaver we could see data as expected with the exactly same SQL.

We tried:

  1. Disable connection pool(set database/sql.DB#maxIdleConnection to 0), the issue can still be reproduced;
  2. Limit the connection pool to 1, the issue can still be reproduced;

We thought cursor may be leaked and we checked database/sql.Rows#Close() and make sure it will be closed finally. We'd also doubt the session state but has very little knowledge about this.

cloorc commented 1 week ago

Oracle db:

Oracle Oracle Database 19c Enterprise Edition
Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

We are using gorm-oracle, which will import go-ora finally, to interact with Oracle database.

go-ora version in go.mod: github.com/sijms/go-ora/v2 v2.8.11.

For following SQL:

SELECT * FROM "t_key" WHERE "tenant_id" = :1 AND "app_id" = :2 AND "dispatching_key" = :3 AND "delete_flag" = :4 ORDER BY "t_key"."id"  FETCH NEXT :5 ROWS ONLY

We occasionally got nothing returned or wrong status in gorm.DB#First(). However, in Dbeaver we could see data as expected with the exactly same SQL.

We tried:

  1. Disable connection pool(set database/sql.DB#maxIdleConnection to 0), the issue can still be reproduced;
  2. Limit the connection pool to 1, the issue can still be reproduced;

We thought cursor may be leaked and we checked database/sql.Rows#Close() and make sure it will be closed finally. We'd also doubt the session state but has very little knowledge about this.

Update: we've enabled CDC on our database(a pdb).

cjbj commented 1 week ago

Have you inserted but not yet committed the data in Dbeaver (or any other connection)?

cloorc commented 1 week ago

Have you inserted but not yet committed the data in Dbeaver (or any other connection)?

I'm sure we'd never inserted, updated or deleted any data at the same time from Dbeaver.

And we disabled supplemental log for CDC and the issue is still.

Thanks a lot!