mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Use READ_COMMITTED serialization level in CreateSyntheticHEA (#1395)
I observed an instance in which a couple queries from this action were, for whatever reason, hanging around as idle for >30 minutes. Assuming the behavior that we saw before where "an open idle serializable transaction means all pg read-locks stick around forever" still holds, that's the reason why the amount of read-locks in use spirals out of control. I'm not sure why those queries aren't timing out, but that's a separate issue.
This commit is contained in:
parent
7fd7828cd8
commit
8a4ac6511b
1 changed files with 10 additions and 0 deletions
|
@ -108,6 +108,16 @@ public class CreateSyntheticHistoryEntriesAction implements Runnable {
|
||||||
return jpaTm()
|
return jpaTm()
|
||||||
.transact(
|
.transact(
|
||||||
() -> {
|
() -> {
|
||||||
|
// Use READ COMMITTED isolation level so that any long-living queries don't cause
|
||||||
|
// collection of predicate locks to spiral out of control (as would happen with a
|
||||||
|
// SERIALIZABLE isolation level)
|
||||||
|
//
|
||||||
|
// NB: setting the isolation level inside the transaction only works for Postgres and
|
||||||
|
// will be reverted to the default once the transaction is committed.
|
||||||
|
jpaTm()
|
||||||
|
.getEntityManager()
|
||||||
|
.createNativeQuery("SET TRANSACTION ISOLATION LEVEL READ COMMITTED")
|
||||||
|
.executeUpdate();
|
||||||
// The class we're searching from is based on which parent type (e.g. Domain) we have
|
// The class we're searching from is based on which parent type (e.g. Domain) we have
|
||||||
Class<? extends HistoryEntry> historyClass =
|
Class<? extends HistoryEntry> historyClass =
|
||||||
getHistoryClassFromParent(resource.getClass());
|
getHistoryClassFromParent(resource.getClass());
|
||||||
|
|
Loading…
Add table
Reference in a new issue