Nikhil 1aabbc83f8 Enable 1PC and DN reads for read only AN txns
In high availability setups, a streaming replica of the access node can
be configured. Since it's a hot standby users should be able to run
read-only queries from this replica and should be able to query the
distributed hypertables from it.

Additionally, the internal code which sets up a connection from the
standby access node to the data nodes now marks the ongoing transaction
explicitly as READ ONLY ones. This ensures that any functions or any
activity which tries to make modifications on the data nodes errors
out. Note that even if "timescaledb.enable_2pc" is enabled, we will
still use 1PC for these READ ONLY transactions.

While we are doing this, we also handle the case when a user explicitly
marks a transaction as "READ ONLY" on the primary AN. Even in that
case the connection to the DNs will be marked read only. Additionally,
similar to the above standby case, even if "timescaledb.enable_2pc" is
enabled, we will still use 1PC for these READ ONLY transactions on the
primary AN.

In normal Postgres standby, the ongoing transaction becomes READ WRITE
immediately on promotion whereas in our case the ongoing transaction
will remain READ ONLY till completion. New transactions on the same
session will be READ WRITE as expected.
2021-11-04 18:38:06 +05:30
..