- Group: V1.1 maintenance --> 1.2 Dev Q
If lock table is included in a statement block in coordinator (we can see this only with statement block in -c option value of psql), lock table is not handled correctly and this end up with inconsistent status.
As shown in the following info, this could be an issue in the coordinator.
The following procedure causes error as follows:
================================
[koichi@buildfarm:pgxc_ctl]$ echo '## BEGIN; LOCK TABLE test01; INSERT INTO test01 VALUES('1', NOW()); COMMIT;'
[koichi@buildfarm:pgxc_ctl]$ psql -p ${port} testdb01 -h ${host} -a -c 'BEGIN; LOCK TABLE test01; INSERT INTO test01 VALUES('1', NOW()); COMMIT;'
BEGIN; LOCK TABLE test01; INSERT INTO test01 VALUES(1, NOW()); COMMIT;
ERROR: Failed to PREPARE the transaction on one or more nodes
[koichi@buildfarm:pgxc_ctl]$ echo ""
[koichi@buildfarm:pgxc_ctl]$
[koichi@buildfarm:pgxc_ctl]$ echo "## SELECT * FROM test01"
[koichi@buildfarm:pgxc_ctl]$ psql -p ${port} testdb01 -h ${host} -a -c 'SELECT * FROM test01'
SELECT * FROM test01
id | data
----+-------------------------------
1 | 2013-12-12 11:28:01.069232+09
1 | 2013-12-12 11:28:01.069232+09
1 | 2013-12-12 11:28:01.069232+09
1 | 2013-12-12 11:28:01.069232+09
(4 rows)
Please note that despite the error, the transaction was not aborted and there's inconsistent data.
Corresponding coordinator log is as follows:
LOG: statement: BEGIN; LOCK TABLE test01; INSERT INTO test01 VALUES(1, NOW()); COMMIT;
ERROR: Failed to PREPARE the transaction on one or more nodes
If the same statement is given via psql command line (and -f option, as well), the script succeeds. In this case, statements are separated by psql as shown in the coordinator log:
testdb01=# BEGIN; LOCK TABLE test01; INSERT INTO test01 VALUES('1', NOW()); COMMIT;
BEGIN
LOCK TABLE
INSERT 0 1
COMMIT
testdb01=# SELECT * FROM test01;
id | data
----+-------------------------------
1 | 2013-12-12 11:29:10.933015+09
(1 row)
LOG: statement: BEGIN;
LOG: statement: LOCK TABLE test01;
LOG: statement: INSERT INTO test01 VALUES('1', NOW());
LOG: statement: COMMIT;
LOG: statement: SELECT * FROM test01;
LOG: statement: delete from test01;
LOG: statement: BEGIN; INSERT INTO test01 VALUES(1, NOW()); COMMIT;
===========================================
Without lock table, the problem does not happen:
[koichi@buildfarm:pgxc_ctl]$ psql -p ${port} testdb01 -h ${host} -a -c 'BEGIN; INSERT INTO test01 VALUES('1', NOW()); COMMIT;'
BEGIN; INSERT INTO test01 VALUES(1, NOW()); COMMIT;
COMMIT
[koichi@buildfarm:pgxc_ctl]$
LOG: statement: BEGIN; INSERT INTO test01 VALUES(1, NOW()); COMMIT;