-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
CockroachDB Support #2002
Comments
@ansarizafar |
Support is implemented in #1993 (comes in release knex 0.13) |
hm... I would say passing version of connected db is implemented, not CockroachDB support. |
@nicck is there some CockroachDB queries which are not compatible with postgresql? If so I'll reopen this as a feature request. |
It's the opposite, PostgreSQL queries not supported by CockroachDB. I mentioned some of them in cockroachdb/cockroach#15299 (comment). CockroachDB is not PostgreSQL, protocol is compatible but CockroachDB support only subset of SQL queries which are valid in PostgreSQL. |
@nicck since cockroach db queries is subset of postgres queries, you should be able to use cockroach db just fine with postgres dialect. Just don't use those features that are not supported by it. |
I can avoid using |
@nicck ah right... those queries done by migration system requires some fixing. At least that select for update could be avoided by some flag which allows migration locking to throw an error instead of blocking (like it did work while ago). So currently migration system is unusable with CockroachDB. Do you know if there are any other problems? |
I was trailing Cockroach DB yesterday and also got stuck on the migrations. Commenting as a plus one and so I can watch the thread. |
Meanwhile that 0.13 doesn't support it you might want to try if 0.12 does. IIRC migrations work a bit different in that version. |
Just tried the migration system and it won't work even with just raw sql. I set my knex-migrations version from 1.3 to 1.2.0 and 1.0.0 but no luck. I don't think I can roll back knex as cockroach requires the version configuration option |
Anyone found a solution to the migrations issue yet?
|
Temporary fix we are using for migrations to work in cockroachdb knexfile.js
|
Would anyone volunteer to create a failing test that would assert not triggering the undesired operation from within migrations? I consider giving this issue a shot if there is any interest in it. |
@mailaneel thank you for your snippet. It worked for me. The one thing, it can lead to errors, because the driver returns string for 64-bit integers, which are not supported in this way. Looking forward for native support of |
Related issue: cockroachdb/cockroach#6583 |
I've discovered another incompatibility. CockroachDB doesn't support savepoints. But the savepoints are a part of Transaction Retries Protocol. This leads to the issue, that the name of savepoint must be Is there any way to retry multi-query transaction with knex (without run all the code again)? |
May be I did something wrong, but it turns out, that there is a more work for supporting the TRP. SAVEPOINT cockroach_restart;
-- if any 40001 error, then
ROLLBACK TO SAVEPOINT cockroach_restart;
-- run full code again |
Since _isLocked is only called just before _lockMigrations, it is redundant and we can accomplish the same thing by checking the rowCount returned by the update (verified by testing with postgres, mysql, sqlite, and mssql). The benefit of this change is improving compatbility with CockroachDB, which does not support FOR UPDATE. Updates knex#2002
@Bessonov You could try extending it, if it can be implemented in a non-breaking way, we might accept the PR. |
Hey all, PM at Cockroach Labs here. We are adding support for savepoints in our upcoming 20.1 release. It will be in our next beta (https://www.cockroachlabs.com/docs/releases/#testing-releases). Let us know if you run into any trouble using it! |
@elhigu @lorefnon @briandamaged @maximelkin Considering popularity of CockroachDB, I'm thinking of adding additional test run configuration to see how many of our tests are failing when PG driver is used to access CockroachDB instance from docker image (could be all of them or most of them). Might be that we do need a separate dialect (extending PG) to handle certain cases; in that case it would probably make sense to create it as a separate repo in knex project and just use as a devDependency to run tests. Thoughts? @awoods187 If your company would consider lending any dev effort towards better support of CockroachDB in knex, that would be greatly appreciated. |
We generally recommend making dialects by forking the PG dialect for these types of tools. We'd be happy to answer any questions and support you along the way. We can also set up a shared slack if that'd be helpful to you. |
@awoods187 thanks for the update. As I can see the docs are not updated yet. How it impacts transaction retry protocol? @kibertoad we run knex + CRDB for a while and doesn't experienced any major problems with pg version 9.6. ATM the only wish we have is to get rid of our custom transaction-retry-protocol implementation. There also some issues with |
We are currently in the process of documenting savepoints cockroachdb/docs#5953 |
Hi, thanks everybody for your work! I'm mostly writing to add a "plus one" to show interest in this feature and to get notifications about further updates, but I also have a question which seems relevant enough to ask here: will this driver support specifying multiple hosts in the connection URL, similarly to what TL;DR - In The |
@kibertoad yeah I know, but if I understand correctly, the EDIT: I think I might be thinking about this the wrong way - instead of you guys making both the Postgres and the Cockroach drivers compatible with both |
@jahudka don't worry about streaming, cockroach doesn't support it. You are right, pg does not have the ability to pass a list of nodes, and I agree that this should be added to the pg package. The problem is in the architecture of different databases using the same postgres dialect, that not all of them work in master-master mode and failover will be different. |
@intech If you have time over the next few months to work on the CockroachDB support, I would like to discuss a sponsorship opportunity. |
Wow, this is unexpected! I have interests to be closer to Cockroach Labs, let's continue communicating by email (we have already communicated with Andy, Rafi and Jesse earlier). |
@intech I've started working on CockroachDB as a Knex dialect. Are there any insights or changes you had to do so far, that you could share? |
@kibertoad After refactoring Knex itself is not yet. Make a cockroachdb branch with base dialect from postgres and we will work on it together. |
Saw already in https://github.com/knex/knex/tree/feat/cockroachdb! |
Any luck yet with migrations and cockroachdb? |
Working on it! |
@intech Rudimentary CockroachDB support landed in master already. Not all tests pass yet, but core functionality should work already. Any chance you could take a look, and maybe you have any code for the driver itself on top of what we currently have that you could share? |
This is coming in 0.95.12, most likely late October! |
@kibertoad great news! Is there any description what the new dialect do or support of crdb mean? I'm asking because we don't experience any problems with postgres dialect beside mentioned workaround. |
@Bessonov It mostly means having knex's test suite pass on CockroachDB, which meant fixing things over pg dialect here and there. You can take a look at https://github.com/knex/knex/tree/master/lib/dialects/cockroachdb or try using 0.95.12-rc1 to help test it for the public release :) |
@kibertoad thanks! I see, changes are minimal. We would try it on the next update batch, but I'm sure it doesn't happen this month :( |
@kibertoad greetings! I'm back and glad to see updates here. |
@intech Appreciate it! |
I believe this can be closed now, correct? |
Yes, support can be tracked by the CockroachDB label and wiki page |
I still need to add
migrate:up works fine. |
@jmsunseri Which knex version? |
"knex": "^0.95.15"
Sincerely,
Justin Sunseri
…On Tue, Jan 18, 2022 at 7:05 PM Igor Savin ***@***.***> wrote:
@jmsunseri <https://github.com/jmsunseri> Which knex version?
—
Reply to this email directly, view it on GitHub
<#2002 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGEPF44EWBFQQSCY6QDPNDUWVCOTANCNFSM4DGZMWTQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Same here, migration running fine on docker with dev mode on, but got error when migrating to remote machine,
|
Please include support for CockroachDB https://www.cockroachlabs.com/
The text was updated successfully, but these errors were encountered: