'PostgreSQL idle_in_transaction_session_timeout seems to have no effect
I'm working with a PostgreSQL server version 10.5 (can't upgrade it at the moment) running in Docker. XL Deploy is connected to it and I upload a new archive that is 232MB. I get the error FATAL: terminating connection due to idle-in-transaction timeout.
In the config, I saw that idle_in_transaction_session_timeout was set to 11000ms. I updated the value to 600000ms and reload the configuration. I see the message LOG: parameter "idle_in_transaction_session_timeout" changed to "600000" in the logs, so I know the setting has taken.
However, when I upload the archive again, I still get the same FATAL timeout message. It's as if the setting is having no effect.
Solution 1:[1]
As it turns out, the issue was in Postgres, but not in the config file. It seems you can update the value of idle_in_transaction_session_timeout at various levels. In my case, it was at the ROLE level. Issuing this SQL statement fixed the timeout.
ALTER ROLE role_abc SET idle_in_transaction_session_timeout = '10min';
Solution 2:[2]
std::initializer_list is a class template that holds a sequence of initializers, which has a very minimal interface since its only purpose is to be used to initialize another object with the sequence of values it contains. Unlike std::vector or std::deque, std::initializer_list is not intended to be used as a general-purpose container.
The function LinkedQueue<T>::LinkedQueue(const std::initializer_list<T>&) is called when someone attempts to list-initialize a LinkedQueue<T>, like this:
LinkedQueue<int> q {1, 2, 3};
The language automatically constructs a std::initializer_list<int> object which contains the values 1, 2, 3, in that order. This object is passed to the constructor. After the constructor returns, the user expects that the newly constructed LinkedQueue<int> object will contain the values 1, 2, 3, in that order.
You need to write the constructor such that this will be true. To do so, you can iterate over the std::initializer_list<T> object using a range-based for loop and add the values in order to the list. Something like this might work, assuming you have a push_back function and a working default constructor:
template<class T>
LinkedQueue<T>::LinkedQueue(const std::initializer_list<T>& il): LinkedQueue() {
for (const T& val : il) {
push_back(val);
}
}
This delegates to the default constructor to set up the class invariants, then inserts the given initializers in order.
Solution 3:[3]
It allows you to initalize your LinkedQueue with {}. as in
LinkedQueue<char> theQueue = {'a','b','c','d','e','f','g','h' };
as well as other things, detailed here on a page about it and it's uses.
Solution 4:[4]
In C++11 an initializer-list is a way to assign content to an object, when several literals are required.
Example, you could initialize a list like:
std::list<int> myList{1,2,3,4,5};
You may write your class, so it accept such syntax.
As a minimalist example, the following function accept a initialization list:
void func( initializer_list<int> intList)
{
for (auto i: intList) /*whatever*/;
}
// used as:
func({1,2,3,5});
Initialization are required to be of the same type: you cannot mix values from different types in the initialization-list.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sffortytwo |
| Solution 2 | Brian Bi |
| Solution 3 | |
| Solution 4 | Adrian Maire |
