Possible issue in 3.3.0 with Multi Tenant - Schema Per Tenant running on postgresql (9.5.6)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Possible issue in 3.3.0 with Multi Tenant - Schema Per Tenant running on postgresql (9.5.6)

Ian Ibbotson
Hey all,

hoping someone might be able to offer some advice - not 100% confident that there is an issue beyond my inability to get things set up properly.

I'm trying to set up postgres schema-per-tenant example, and have a test project here:

https://github.com/ianibo/Grails330PGSchmaPerTenantTestCase

To run this, you'll need a postgres user with perms to create schema, perhaps using the following (as postgres user)

CREATE DATABASE spttest;
CREATE USER spttest WITH PASSWORD 'spttest' SUPERUSER CREATEDB INHERIT LOGIN;
GRANT ALL PRIVILEGES ON DATABASE spttest
to spttest;
I'm running in a linux environment, which seems to have some separate issues with case sensitivity around schema names in the interaction between SchemaHandler and groovy.org.grails.orm.hibernate.HibernateDatastore [1]. The test app works around that by providing a custom SchemaHandler that sets up 2 explicit schemas/tenants (test1 and test2) instead of enumerating the schemas via JDBC.

What I'm seeing is that the app starts up, but creates the book table only in the public schema, rather than 2 separate tables in each schema. My implementation of SchemaHandler is overriding useSchema to use the postgres variant

useSchemaStatement = "SET search_path TO %s,public"

I'm wondering if 
(a) anyone can see what I'm doing wrong? 
(b) suggest a way of fixing it (I'm happy to help) and 
(c) I'd actually like to try and dig into this a little myself - are there any guides to setting up a tool like intellij to be able to  breakpoint / debug step into the framework code. Going to have a play with this, but any shortcuts would be most welcome.
(d) I've put the MultiTenant trait on the domain class - not sure this is needed for Schema per tenant?
Cheers,
Ian.



[1]  Currently Line 407 https://github.com/grails/gorm-hibernate5/blob/master/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/HibernateDatastore.java - I think

if(schemaName.equals("INFORMATION_SCHEMA") || schemaName.equals("PUBLIC")) continue;

Needs to be using equalsIgnoreCase

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/afaaa7c8-476b-4c33-bbb9-27ec021ce3aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.