Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: Drupal compatibility with CockroachDB #22211

Open
knz opened this issue Jan 30, 2018 · 15 comments
Open

sql: Drupal compatibility with CockroachDB #22211

knz opened this issue Jan 30, 2018 · 15 comments
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) meta-issue Contains a list of several other issues. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@knz
Copy link
Contributor

knz commented Jan 30, 2018

So Drupal is a very popular open source CMS which is used to power many public web sites.

Currently Drupal does not work with CockroachDB.

At least one issue is the following: sql: Support 'COMMENT ON TABLE foo is 'bar' #19472

Jira issue: CRDB-5870

@knz knz added the A-sql-pgcompat Semantic compatibility with PostgreSQL label Jan 30, 2018
@knz knz added this to the Later milestone Jan 30, 2018
@knz
Copy link
Contributor Author

knz commented Jan 30, 2018

cc @awoods187 for prioritization

@knz
Copy link
Contributor Author

knz commented Jan 30, 2018

Issue #19472 was closed but we do not know if that was sufficient to enable compatibility.

@lotyrin
Copy link

lotyrin commented Feb 8, 2018

Just spun up Drupal and Cockroach, currently the install fails as a consequence of #20782

@jchristi
Copy link

#20782 has been resolved. @lotyrin is Drupal able to install now?

@knz knz added the meta-issue Contains a list of several other issues. label Jun 22, 2018
@lotyrin
Copy link

lotyrin commented Jun 24, 2018

Building from git on OSX and in Docker (using the builder image) didn't work out for me. Once there's an unstable docker image with this change in it, I can easily try again.

@lotyrin
Copy link

lotyrin commented Jun 24, 2018

Ironed out OSX build from git (had to use go get to get paths right).

@jchristi The bytea session variable seems to work, but Drupal sees it set to hex and tries to set it to escape at the schema level (ALTER DATABASE "drupal" SET bytea_output = 'escape';) which doesn't seem to be supported.

There is also a message regarding detecting encoding - "Drupal could not determine the encoding of the database was set to UTF-8", which is the result of SHOW server_encoding; and that variable being unavailable.

Further, it makes a call to pg_advisory_lock() which is not available.

@knz
Copy link
Contributor Author

knz commented Jun 25, 2018

Thank you for trying it out! I have filed the related issues:

We also have a previous issue for pg_advisory_lock:

@lotyrin can you detail how Drupal uses pg_advisory_lock()? What does it expect to do with it?

@lotyrin
Copy link

lotyrin commented Jun 25, 2018

@knz No problem! Re: pg_advisory_lock(), that is a really good question, I will see if I can find out.

@lotyrin
Copy link

lotyrin commented Jun 27, 2018

Drupal, when initializing a schema for use, adds a couple compatibility shim functions. Drupal.org was experiencing test failures due to race conditions within Postgres' implementation of CREATE OR REPLACE FUNCTION so they wrapped the sequence with pg_advisory_lock().

Call to pg_advisory_lock()
Issue
Test results with race condition

If cockroach supports atomic CREATE OR REPLACE FUNCTION where two simultaneous queries are both guaranteed to complete (not distinct test-if-exists followed by either a create or a replace, where the conditions of the initial test might have changed) then this lock is superfluous.

@knz
Copy link
Contributor Author

knz commented Jun 27, 2018

what are these compatibility shim functions that drupal needs to add? Is this limited to the two functions rand() and substring_index()? If CockroachDB were to predefine these two, would there be a way to teach Drupal to avoid setting up these user-defined functions altogether?

@lotyrin
Copy link

lotyrin commented Jun 27, 2018

Yep, just those two. Drupal shouldn't be creating any functions other than those, and it does check if they exist before trying to create them.

@lotyrin
Copy link

lotyrin commented Jun 27, 2018

Modifying Drupal to skip these checks / functions and proceed further into in the installation, the next issue is that it checks the variable max_identifier_length.

If I skip that, I get an error about COMMENT ON TABLE not being implemented (Drupal checks if the comment is successful and doesn't continue). If I skip that it tries to COMMENT ON COLUMN with the same results.

If I skip that, it tries to use SAVEPOINT.

All in all, Drupal's pgsql driver seems to be fairly heavily invested in PostgreSQL implementation detail.

@knz
Copy link
Contributor Author

knz commented Jun 27, 2018 via email

@lotyrin
Copy link

lotyrin commented Jun 27, 2018

The use of SAVEPOINT was added here: https://www.drupal.org/project/drupal/issues/2487269

It seems other RDBMS they support allowed continued use of a transaction in the case that queries have failed, but Postgres does not, so they wrap every query with a savepoint to emulate the behavior.

@knz
Copy link
Contributor Author

knz commented Jun 27, 2018 via email

@knz knz added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Jul 21, 2018
@knz knz changed the title Drupal compatibility with CockroachDB sql: Drupal compatibility with CockroachDB Jul 23, 2018
@petermattis petermattis removed this from the Later milestone Oct 5, 2018
@rafiss rafiss added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) meta-issue Contains a list of several other issues. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

No branches or pull requests

5 participants