diff options
| author | Abbas | 2011-05-02 14:16:38 +0000 |
|---|---|---|
| committer | Pavan Deolasee | 2011-05-24 10:33:32 +0000 |
| commit | ba0c6b460db82dbd38b5d2cb2d86c9ee36d3adc3 (patch) | |
| tree | 62845c359dc83edf9a18248e5b9d30ccf705f88c /src/include | |
| parent | 7a810c69a82a7d5990e922ee653b2301b1f91f2b (diff) | |
This patch fixes TWO bugs 3273569 & 3243469
The problem was that prepared transactions were not being listed in
the system view pg_prepared_xacts.
The reason was that in XC transactions are not prepared on the coordinator and
hence the function pg_prepared_xact does not return any. The main worker function
GetPreparedTransactionList which is supposed to return an array of prepared
transactions for the user level function pg_prepared_xact, always finds ZERO
in TwoPhaseState->numPrepXacts, since the transaction was never prepared on the
coordinator.
The solution was to ask data nodes, where the transaction was actually prepared.
All data nodes may not be involved in all transactions hence we have to ask
all data nodes in any case.
In order to implement this solution we created two schemas,
__pgxc_datanode_schema__ & __pgxc_coordinator_schema__
one for data nodes and one for coordinators respectively.
Next these schemas were added to the default search path in coordinator
as well as on data node.
Hence the default search path on coordinator is
"$user",public, __pgxc_coordinator_schema__
and on the data node is
"$user",public, __pgxc_datanode_schema__
Next we created a table named pg_prepared_xact in the schema __pgxc_coordinator_schema__
with the same fields as the old view pg_prepared_xact.
and we created the old view pg_prepared_xact in the schema __pgxc_datanode_schema__.
Now when a query for the view pg_prepared_xact is launched on the coordinator,
it knows it is a table distributed in round robin fashion on all data nodes and hence
it generates a query to ask all data nodes.
The only difference will be that if we have two data nodes and the transaction was
prepared on both we will get two rows for it which is correct. If one row per
transaction is required all that is required is to add distinct in the query.
A few changes in this patch are due to the following two limitations
which are not addressed by this patch.
1. create table in system_view.sql does not enter a corresponding row in pgxc_class.
2. We need to ROLLBACK manually after a PREPARE TRANSCATION fails due to name duplication.
The prepared_xacts.sql test case now passes, and hence successive regression runs are
now possible.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/pgxc/locator.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/include/pgxc/locator.h b/src/include/pgxc/locator.h index 3272ab6cb1..9f669d92e0 100644 --- a/src/include/pgxc/locator.h +++ b/src/include/pgxc/locator.h @@ -28,6 +28,10 @@ #define IsReplicated(x) (x->locatorType == LOCATOR_TYPE_REPLICATED) +#define PGXC_COORDINATOR_SCHEMA "__pgxc_coordinator_schema__" +#define PGXC_DATA_NODE_SCHEMA "__pgxc_datanode_schema__" +#define PREPARED_XACTS_TABLE "pg_prepared_xacts" + #include "nodes/primnodes.h" #include "utils/relcache.h" |
