Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfnjV-0007bO-LO for pljava-dev@arkaria.postgresql.org; Thu, 19 Nov 2020 17:28:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kfnjU-0006t7-G4 for pljava-dev@arkaria.postgresql.org; Thu, 19 Nov 2020 17:28:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfnjU-0006t0-0u for pljava-dev@lists.postgresql.org; Thu, 19 Nov 2020 17:28:32 +0000 Received: from anastigmatix.net ([68.171.219.55]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfnjM-000381-SL for pljava-dev@lists.postgresql.org; Thu, 19 Nov 2020 17:28:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vRrycYqcjvHvakFptFPkD5lUo5VBZm+LPc3yuP6ch2M=; b=HgOeHpBUv40x7NErZa9xou0EsN ZW7Tdw2Pi8vS1tC345JXKgWEoD/9Q+VUlddx7wM4joQnHcXZECvJYOPg20e5UGB4Za4TIHDSZoXXR UVOpguYBWsMk19A+YvOx1/ZUzHDpLxjk1s9lnnqMBqdHLlWrDzpmImx7tIYZSTreYdPXnbUIaePBF ZG+1pug7p/DLzMjMGdimsn40J6E2+n6JYCAS1YDEDsKQG6aOZn4BcoUgjer8N+Es0AeukvNHYeZZh Mk7IxjvVKRJaeyKLFFBJBNWS6lALRqjTHGmt2dJS300QYpnsOnZ1U/3bkkF4yZsJTZoWFFo6TC+mI lV98OKGA==; Received: from [184.19.31.139] (port=54984) by bay.acenet.us with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kfnjK-007b69-2Z; Thu, 19 Nov 2020 12:28:22 -0500 Subject: Re: Fail to create distributed table in Citus To: Erik Mata , pljava-dev@lists.postgresql.org References: From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5FB6AB35.5060101@anastigmatix.net> Date: Thu, 19 Nov 2020 12:28:21 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=-95.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/19/20 10:23, Erik Mata wrote: > 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. That's kind of fascinating. Have you also raised this in a Citus-specific list? They might hold some pieces of the puzzle. :) > 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 ... The jdbc:default:connection in PL/Java really isn't a new connection of any kind; the JVM is running inside the PostgreSQL backend process that is handling your existing connection, and the jdbc:default:connection is no more than a JDBC-like wrapper over SPI. It is largely the same as if you wrote your test_create_distributed_table() function in C, and it contained Datum test_create_distributed_table(PG_FUNCTION_ARGS) { ... SPI_execute("CREATE TABLE test1 (a BIGINT PRIMARY KEY)", false, 0); SPI_execute("SELECT create_distributed_table(" "'test1', 'a', colocate_with=>'none')", false, 0); ... } (It might even be interesting to write a C version like that, and see what it does.) There seems to be something about create_distributed_table() that doesn't work when it is invoked in that context, and even more oddly, seems to be failing silently, rather than reporting an error of some kind. Are you able to share your Java code? I'm sure it is straightforward, but maybe it would help to pin the details down. I think the Citus create_distributed_table source is here https://github.com/citusdata/citus/blob/v9.5.0/src/backend/distributed/commands/create_distributed_table.c but in a quick skim I haven't had anything jump out at me as where it might be failing. Yet. Regards, -Chap