pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #12808: BDR lock adding Postgis extension in one node
5+ messages / 4 participants
[nested] [flat]

* BUG #12808: BDR lock adding Postgis extension in one node
@ 2015-02-26 16:29 rmelendo@teltronic.es
  2015-02-27 14:24 ` Re: BUG #12808: BDR lock adding Postgis extension in one node Andres Freund <andres@2ndquadrant.com>
  0 siblings, 1 reply; 5+ messages in thread

From: rmelendo@teltronic.es @ 2015-02-26 16:29 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      12808
Logged by:          Ruth Melendo
Email address:      rmelendo@teltronic.es
PostgreSQL version: 9.4.1
Operating system:   Ubuntu 14.04 LTS
Description:        

Using BDR with 2 nodes and trying to add a PostGIS extension in node 1, it
adds the extension and automatically adds “spatial_ref_sys”.

In node2, it tries to add the extension and gets an error because table
“spatial_ref_sys” does not exists. The bbdd gets locked after that.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #12808: BDR lock adding Postgis extension in one node
  2015-02-26 16:29 BUG #12808: BDR lock adding Postgis extension in one node rmelendo@teltronic.es
@ 2015-02-27 14:24 ` Andres Freund <andres@2ndquadrant.com>
  2015-02-27 14:30   ` Re: BUG #12808: BDR lock adding Postgis extension in one node Ruth Melendo <rmelendo@teltronic.es>
  0 siblings, 1 reply; 5+ messages in thread

From: Andres Freund @ 2015-02-27 14:24 UTC (permalink / raw)
  To: rmelendo@teltronic.es; +Cc: pgsql-bugs

Hi,

On 2015-02-26 16:29:25 +0000, rmelendo@teltronic.es wrote:
> Using BDR with 2 nodes and trying to add a PostGIS extension in node 1, it
> adds the extension and automatically adds “spatial_ref_sys”.
> 
> In node2, it tries to add the extension and gets an error because table
> “spatial_ref_sys” does not exists. The bbdd gets locked after that.

(this isn't the best forum for this, but I don't really know what to
recommend besides -general)

What's the exact error message? Does it out because of the extension or
because of inserts into that table?

Which version of bdr does this happen with? Because I seem to recall
fixing a similar problem... If not, we'll look into the issue.

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #12808: BDR lock adding Postgis extension in one node
  2015-02-26 16:29 BUG #12808: BDR lock adding Postgis extension in one node rmelendo@teltronic.es
  2015-02-27 14:24 ` Re: BUG #12808: BDR lock adding Postgis extension in one node Andres Freund <andres@2ndquadrant.com>
@ 2015-02-27 14:30   ` Ruth Melendo <rmelendo@teltronic.es>
  2015-02-28 09:36     ` Re: BUG #12808: BDR lock adding Postgis extension in one node 'Andres Freund' <andres@2ndquadrant.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Ruth Melendo @ 2015-02-27 14:30 UTC (permalink / raw)
  To: 'Andres Freund' <andres@2ndquadrant.com>; +Cc: pgsql-bugs

The error got when adding a PostGIS extension from PGAdmin in node 1. Extension was created and the depending table too but in node 2 got the error when adding the extension because the depending table was not created. 

But, although the problem was originated for this, my main dude is how to fix the database then it´s locked. What do I have to do? Because now, I cannot do any DDL or DML against it.


Ruth Patricia Melendo Ventura
Software Engineer
TELTRONIC, S.A.U.
T: +34 976 465656   Ext. 179
F: +34 976 465722 
www.teltronic.es


-----Mensaje original-----
De: Andres Freund [mailto:andres@2ndquadrant.com] 
Enviado el: viernes, 27 de febrero de 2015 15:24
Para: rmelendo@teltronic.es
CC: pgsql-bugs@postgresql.org
Asunto: Re: [BUGS] BUG #12808: BDR lock adding Postgis extension in one node

Hi,

On 2015-02-26 16:29:25 +0000, rmelendo@teltronic.es wrote:
> Using BDR with 2 nodes and trying to add a PostGIS extension in node 
> 1, it adds the extension and automatically adds “spatial_ref_sys”.
> 
> In node2, it tries to add the extension and gets an error because 
> table “spatial_ref_sys” does not exists. The bbdd gets locked after that.

(this isn't the best forum for this, but I don't really know what to recommend besides -general)

What's the exact error message? Does it out because of the extension or because of inserts into that table?

Which version of bdr does this happen with? Because I seem to recall fixing a similar problem... If not, we'll look into the issue.

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #12808: BDR lock adding Postgis extension in one node
  2015-02-26 16:29 BUG #12808: BDR lock adding Postgis extension in one node rmelendo@teltronic.es
  2015-02-27 14:24 ` Re: BUG #12808: BDR lock adding Postgis extension in one node Andres Freund <andres@2ndquadrant.com>
  2015-02-27 14:30   ` Re: BUG #12808: BDR lock adding Postgis extension in one node Ruth Melendo <rmelendo@teltronic.es>
@ 2015-02-28 09:36     ` 'Andres Freund' <andres@2ndquadrant.com>
  2015-03-02 09:29       ` Re: BUG #12808: BDR lock adding Postgis extension in one node Ruth Melendo <rmelendo@teltronic.es>
  0 siblings, 1 reply; 5+ messages in thread

From: Andres Freund @ 2015-02-28 09:36 UTC (permalink / raw)
  To: Ruth Melendo <rmelendo@teltronic.es>; +Cc: pgsql-bugs

Hi,

[some information has been acquired privately]

On 2015-02-27 15:30:20 +0100, Ruth Melendo wrote:
> The error got when adding a PostGIS extension from PGAdmin in node
> 1. Extension was created and the depending table too but in node 2 got
> the error when adding the extension because the depending table was
> not created.

> But, although the problem was originated for this, my main dude is how
> to fix the database then it´s locked. What do I have to do? Because
> now, I cannot do any DDL or DML against it.

The reason it's locked is that it's waiting for DDL to be
replicated. And that fails due to the spatial_ref_sys error.

In the version you're using the easiest way to resolve this is probably
to skip replication of the problematic transaction, and then fix up
things afterwards by hand.

To do that connect to the database you performed the CREATE EXTENSION
on. There get a list of the outgoing connections with a query like:

SELECT slot_name, datoid, database, active
FROM pg_replication_slots
WHERE slot_name LIKE 'bdr_'||(SELECT oid FROM pg_database WHERE datname = current_database())||'_%';
┌─────────────────────────────────────────┬────────┬──────────┬────────┐
│                slot_name                │ datoid │ database │ active │
├─────────────────────────────────────────┼────────┼──────────┼────────┤
│ bdr_17911_6120567807158814813_1_16385__ │  17911 │ node_03  │ t      │
│ bdr_17911_6120567807158814813_1_17153__ │  17911 │ node_03  │ f      │
└─────────────────────────────────────────┴────────┴──────────┴────────┘
(2 rows)

In my three node setup those two consume changes from the node_03
database.

To consume the problematic transaction, use something like:

COPY (SELECT * FROM pg_logical_slot_get_binary_changes('bdr_17911_6120567807158814813_1_16385__', NULL, 1, 'interactive', 'true')) TO '/dev/null';

for each of the remote nodes. After that you should be able to execute
DDL again.

Then please reconnect and do
SET bdr.skip_ddl_replication = on;
DROP EXTENSION postgis;

That should bring the nodes back in sync with regard to the postgis
extension.


We'll work on making it possible to replicate extensions that insert
data into their own tables during creation.

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #12808: BDR lock adding Postgis extension in one node
  2015-02-26 16:29 BUG #12808: BDR lock adding Postgis extension in one node rmelendo@teltronic.es
  2015-02-27 14:24 ` Re: BUG #12808: BDR lock adding Postgis extension in one node Andres Freund <andres@2ndquadrant.com>
  2015-02-27 14:30   ` Re: BUG #12808: BDR lock adding Postgis extension in one node Ruth Melendo <rmelendo@teltronic.es>
  2015-02-28 09:36     ` Re: BUG #12808: BDR lock adding Postgis extension in one node 'Andres Freund' <andres@2ndquadrant.com>
@ 2015-03-02 09:29       ` Ruth Melendo <rmelendo@teltronic.es>
  0 siblings, 0 replies; 5+ messages in thread

From: Ruth Melendo @ 2015-03-02 09:29 UTC (permalink / raw)
  To: 'Andres Freund' <andres@2ndquadrant.com>; +Cc: pgsql-bugs

Thanks for your explanation Andres. It worked for me.

Just 3  more questions:

1.- Should I get a newer version of BDR? Does mine have important bugs? I´m testing that for production env in a near future and the application in production in my company depends on these results.

2.- I don’t understand exactly what I´m doing with this sentence: COPY (SELECT * FROM pg_logical_slot_get_binary_changes('bdr_17911_6120567807158814813_1_16385__', NULL, 1, 'interactive', 'true')) TO '/dev/null'; 
I suppose I´m discarding the changes. That will make my changes to be discarded or are you counting with bdr.initial_copy activated to get them again? 

3.- When I do this:
SET bdr.skip_ddl_replication = on;
Is it the same as commenting the bdr properties in postgres.conf?

As I´m testing for production env, I need to write a procedure to recover database when getting an error like this one. I have gotten similar errors more times when doing tests, in transactions DDL or DML, I guess my fault in any configuration property. When I get to that situation, should I follow the same instructions?

Instructions to recover database when gets corrupted after bdr error:

1- Skip replication of the problematic transaction. 
	SELECT slot_name, datoid, database, active FROM pg_replication_slots WHERE slot_name LIKE 'bdr_'||(SELECT oid FROM pg_database WHERE datname = 	current_database())||'_%';

	COPY (SELECT * FROM pg_logical_slot_get_binary_changes('bdr_17911_6120567807158814813_1_16385__', NULL, 1, 'interactive', 'true')) TO '/dev/null';

2.- Reconnect to the database and execute

	SET bdr.skip_ddl_replication = on;
	DROP EXTENSION postgis;

Should it be something like that or should I delete the data directory in the problematic node and create the cluster again so that the bdr.init_copy bring the database to a right state?

Thanks again!

Ruth Patricia Melendo Ventura
Software Engineer
TELTRONIC, S.A.U.
T: +34 976 465656   Ext. 179
F: +34 976 465722 
www.teltronic.es


-----Mensaje original-----
De: 'Andres Freund' [mailto:andres@2ndquadrant.com] 
Enviado el: sábado, 28 de febrero de 2015 10:36
Para: Ruth Melendo
CC: pgsql-bugs@postgresql.org
Asunto: Re: [BUGS] BUG #12808: BDR lock adding Postgis extension in one node

Hi,

[some information has been acquired privately]

On 2015-02-27 15:30:20 +0100, Ruth Melendo wrote:
> The error got when adding a PostGIS extension from PGAdmin in node 1. 
> Extension was created and the depending table too but in node 2 got 
> the error when adding the extension because the depending table was 
> not created.

> But, although the problem was originated for this, my main dude is how 
> to fix the database then it´s locked. What do I have to do? Because 
> now, I cannot do any DDL or DML against it.

The reason it's locked is that it's waiting for DDL to be replicated. And that fails due to the spatial_ref_sys error.

In the version you're using the easiest way to resolve this is probably to skip replication of the problematic transaction, and then fix up things afterwards by hand.

To do that connect to the database you performed the CREATE EXTENSION on. There get a list of the outgoing connections with a query like:

SELECT slot_name, datoid, database, active FROM pg_replication_slots WHERE slot_name LIKE 'bdr_'||(SELECT oid FROM pg_database WHERE datname = current_database())||'_%'; ┌─────────────────────────────────────────┬────────┬──────────┬────────┐
│                slot_name                │ datoid │ database │ active │
├─────────────────────────────────────────┼────────┼──────────┼────────┤
│ bdr_17911_6120567807158814813_1_16385__ │  17911 │ node_03  │ t      │
│ bdr_17911_6120567807158814813_1_17153__ │  17911 │ node_03  │ f      │
└─────────────────────────────────────────┴────────┴──────────┴────────┘
(2 rows)

In my three node setup those two consume changes from the node_03 database.

To consume the problematic transaction, use something like:

COPY (SELECT * FROM pg_logical_slot_get_binary_changes('bdr_17911_6120567807158814813_1_16385__', NULL, 1, 'interactive', 'true')) TO '/dev/null';

for each of the remote nodes. After that you should be able to execute DDL again.

Then please reconnect and do
SET bdr.skip_ddl_replication = on;
DROP EXTENSION postgis;

should bring the nodes back in sync with regard to the postgis extension.That 


We'll work on making it possible to replicate extensions that insert data into their own tables during creation.

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2015-03-02 09:29 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26 16:29 BUG #12808: BDR lock adding Postgis extension in one node rmelendo@teltronic.es
2015-02-27 14:24 ` Andres Freund <andres@2ndquadrant.com>
2015-02-27 14:30   ` Ruth Melendo <rmelendo@teltronic.es>
2015-02-28 09:36     ` 'Andres Freund' <andres@2ndquadrant.com>
2015-03-02 09:29       ` Ruth Melendo <rmelendo@teltronic.es>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox