Oracle lag between commit and select

前端 未结 8 1899
攒了一身酷
攒了一身酷 2020-12-29 12:00

We have an Java workflow application that uses an Oracle database to track its steps and interactions with other services. During a workflow run several insert/update/selec

8条回答
  •  囚心锁ツ
    2020-12-29 12:18

    This sounds like an issue with RAC, with connections to two different instances and the SCN is out of sync.

    As a workaround, consider not closing the database connection and getting a new one, but reuse the same connection.

    If that's not workable, then add a retry to the query that attempts to retrieve the inserted row. If the row is not returned, then sleep a bit, and retry the query again. Put that into a loop, after a specified number of retries, you can then fail.

    [ADDENDUM]

    In his answer, Steve Broberg (+1!) raises interesting ideas. I hadn't considered:

    • the COMMIT might be anything other than IMMEDIATE WAIT
    • the transaction isolation level might be anything other than READ COMMITTED

    I did consider the possibility of flashback query, and dismissed that out of hand without mentioning it, as there's no apparent reason the OP would be using flashback query, and no evidence of such a thing in the code snippet.)

    [/ADDENDUM]

提交回复
热议问题