Feature #8989
Add support for multiple dialects for the multi-tenant landlord database
100%
History
#1 Updated by Radu Apetrii about 2 years ago
- In
TenantManager$TenantSQL.CREATE_SYSTEM_TABLE, the columnpam_library_checksumis of typeBINARY(the equivalent ofRAWfrom 4GL). The keywordBINARYis H2 specific and needs to be modified according to the dialect in use. - In
TenantManager$TenantSQL, bothINSERT_DOMAINandINSERT_DOMAIN_TYPEuseMERGE INTO. The original intention was to skip adding a specific record if it already exists, but since H2 doesn't offer a straight-forward approach, I opted for this.- For reference, in MariaDB, one can use
INSERT IGNOREand in PostgreSQL, one can useINSERT ... ON CONFLICT DO NOTHING.
- For reference, in MariaDB, one can use
- When the support for multiple dialects will be implemented, the dialect will need to be extracted from the URL. In order to achieve this, there is a bit of code in
DatabaseManager.createSettingsthat handles this exact thing. This could be used as a reference point.
If other changes appear in the meantime, I'll keep this task up to date.
#3 Updated by Ovidiu Maxiniuc over 1 year ago
- Assignee set to Ovidiu Maxiniuc
- Status changed from New to WIP
I've started implementing this feature. For the moment, PostgreSQL seems to be working in my small test cases. I will create the associated branch tomorrow, after additional tests.
I also update the wiki page to help with setup and configuration of the landlord database in directory.xml.
#4 Updated by Eric Faulhaber over 1 year ago
- reviewer Radu Apetrii added
#5 Updated by Ovidiu Maxiniuc over 1 year ago
- Status changed from WIP to Review
- % Done changed from 0 to 100
I created task branch 8989a and committed the changes. Supported dialects are H2, PSQL, MariaDb (for SQL Server, the effort was deferred to a later task).
Radu, please review.
#6 Updated by Radu Apetrii over 1 year ago
- This is like the smallest complaint ever, but in
MariaDbLenientDialectand inP2JH2Dialect, the return statement of the functionsgetCreateMasterTable()andgetCreateDatabasesTable()is a bit misaligned.- How it is currently:
return "CREATE TABLE IF NOT EXISTS master (\n"+ " tenant_id UUID NOT NULL,\n" + - How it should be:
return "CREATE TABLE IF NOT EXISTS master (\n" + " tenant_id UUID NOT NULL,\n" +
- How it is currently:
- I see that
getTenantSql()is not yet implemented inP2JSQLServer2008Dialect. I believe there aren't any clients that will make use of it at the moment, but my question is: should that part stay unimplemented for now, and when we'll need it, we'll go and implement it? Or should we approach this with another strategy? - The first line of javadoc in
Dialect.TenantSQLhas over 110 characters.
From a logical point of view, I have no observations. In terms of testing, did everything go well?
#7 Updated by Ovidiu Maxiniuc over 1 year ago
Radu Apetrii wrote:
Review for 8989a:
- This is like the smallest complaint ever, but in
MariaDbLenientDialectand inP2JH2Dialect, the return statement of the functionsgetCreateMasterTable()andgetCreateDatabasesTable()is a bit misaligned.
OK, thank you for noticing this. It was the result of copy/paste and the IDE trying to be smarter and tab-aligning (3x spaces) the strings instead of keeping the indent from previous string. Fixed.
- I see that
getTenantSql()is not yet implemented inP2JSQLServer2008Dialect. I believe there aren't any clients that will make use of it at the moment, but my question is: should that part stay unimplemented for now, and when we'll need it, we'll go and implement it? Or should we approach this with another strategy?
I added an implementation for SQL Server, too. However, because MS prefers not to implement IF NOT EXISTS, the code for achieving the same is much more complex.
- The first line of javadoc in
Dialect.TenantSQLhas over 110 characters.
Sorry, I see it at exactly 110.
From a logical point of view, I have no observations. In terms of testing, did everything go well?
All the tests were successful. I insisted on PSQL as being the target and H2 - to avoid regressions. I was not able to test MSSQL ATM. Maybe I will do this these days. Except that, no regressions.
BTW, I updated the Multi-Tenancy to include the information on supported dialects and basic instructions on how to configure it.
#8 Updated by Eric Faulhaber over 1 year ago
- Status changed from Review to Merge Pending
Please merge 8989a to trunk now.
#9 Updated by Ovidiu Maxiniuc over 1 year ago
- Status changed from Merge Pending to Test
Branch 8989a was merged into trunk as rev. 15658 and archived.
#10 Updated by Eric Faulhaber over 1 year ago
Lorian, Greg asked that we test trunk/15658 with the customer harness before we push it to customers. Since this is not working for Ovidiu at the moment, would you please run a harness test with this revision and report the result here? Thanks.
#11 Updated by Eric Faulhaber over 1 year ago
Ovidiu Maxiniuc wrote:
BTW, I updated the Multi-Tenancy to include the information on supported dialects and basic instructions on how to configure it.
Ovidiu, I read through this section of the documentation. One thing that was not fully clear to me: with 8989a now merged to trunk, does the absence of the landlord_database_url element in directory.xml now represent an error, or will the runtime default to its pre-8989a behavior of creating an H2 landlord database?
Since multiple people are now testing with multi-tenancy enabled, we need to know if those environments will break when this feature is picked up.
#12 Updated by Ovidiu Maxiniuc over 1 year ago
Eric Faulhaber wrote:
The documentation specifies that "Multitenancy is enabled by defining the URL of the landlord database". Otherwise, we have:Ovidiu, I read through this section of the documentation. One thing that was not fully clear to me: with 8989a now merged to trunk, does the absence of the
landlord_database_urlelement indirectory.xmlnow represent an error, or will the runtime default to its pre-8989a behavior of creating an H2 landlord database?
- if the
landlord_database_urlis not set, the multi-tenancy is NOT enabled, not an error. Just running in regular ST mode where all tenant-related functionalities are disabled. - if it contains an invalid string, the FWD server will start but when the string fails to be parsed by
DriverManager, an error ("Cannot connect to the landlord database due to <error-cause>) will be logged. I have not done more exploratory testing/debugging in this case;
Since multiple people are now testing with multi-tenancy enabled, we need to know if those environments will break when this feature is picked up.
That's cool.
The branch 8989a does not change anything functionally, just adds support for new dialects for storing landlord database.
#13 Updated by Lorian Sandu over 1 year ago
Eric Faulhaber wrote:
Lorian, Greg asked that we test trunk/15658 with the customer harness before we push it to customers. Since this is not working for Ovidiu at the moment, would you please run a harness test with this revision and report the result here? Thanks.
Tested harness and it was ok ✅.
#14 Updated by Greg Shah over 1 year ago
Trunk rev 15662 was pushed to xfer.