Fail to create distributed table in Citus

From: Erik Mata <erikmata(at)gmail(dot)com>
To: pljava-dev(at)lists(dot)postgresql(dot)org
Subject: Fail to create distributed table in Citus
Date: 2020-11-19 15:23:26
Message-ID: CAB0C2fn42hT7RQGK+MwTG-rnxj6eKEhnBr3vyjvZsVOu0gv7qQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

I have set up a local docker environment with a total of 4 Postgres server
instances, all including Citus (9.5.0) and PL/JAVA (1.6.1) extensions:
- 1 as Citus master
- 3 as Citus workers

I have set up a simple routine in PL/JAVA which creates a table and
requests that the table be distributed in the cluster, as:

CREATE TABLE test1 (a BIGINT PRIMARY KEY);
SELECT create_distributed_table('test1', 'a', colocate_with=>'none');

I connect to the Citus master server via a JDBC-connection to localhost.
I then call the PL/JAVA routine, as:

SELECT test_create_distributed_table();

This results in a local table being created on the Citus master node, but
no tables are created on the workers and the Citus utility functions tell
me that the table is NOT distributed.

If I use the same statements that I have included in the PL/JAVA routine
(see above), but I execute them from within e.g. DataGrip, connected to the
Citus master node, the table is created and distributed correctly. I can
see that the correct tables are created on the workers and the Citus
utility functions tell me that the table is indeed distributed.

So, it seems that there is nothing wrong with my setup (cluster).

The problem, as far as I can tell, should be somewhere in how PL/JAVA
connects to the Citus master node. The PL/JAVA routine runs in a JVM that
is spawned by the Postgres server process on the Citus master node. The
PL/JAVA routine acquires a connection to the local database via a somewhat
fake JDBC-connection (jdbc:default:connection) as explained in the PL/JAVA
documentation.

I suspect that this fake JDBC-connection is the reason that the Citus
master node is unable to distribute the table to the rest of the cluster
nodes.

As a side-note: From within PL/JAVA routines, I am able to execute other
types of statements that interact with distributed tables created outside
of the PL/JAVA routine. I am able to DROP, TRUNCATE, INSERT, UPDATE, DELETE
etc. Just not SELECT create_distributed_table.

Any help is appreciated!

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Chapman Flack 2020-11-19 17:28:21 Re: Fail to create distributed table in Citus
Previous Message Chapman Flack 2020-11-17 23:08:10 PL/Java 1.6.1 and 1.5.7 announced