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 connector #1705

Open
realtsiry opened this Issue Jan 21, 2018 · 19 comments

Comments

Projects
None yet
@realtsiry
Copy link

realtsiry commented Jan 21, 2018

This feature requests serves as a central place to discuss development and progress for the CockroachDB connector.

@nvanbenschoten

This comment has been minimized.

Copy link

nvanbenschoten commented Feb 7, 2018

This would be great! CockroachDB implements the PostgreSQL wire protocol, almost all of its syntax, and the majority of its data types like jsonb and arrays. As such, as long as no particularly obscure features are used, this should come for free with https://github.com/graphcool/prisma/issues/1641.

@jensneuse

This comment has been minimized.

Copy link

jensneuse commented Feb 21, 2018

Cockroachdb's underlying architecture is a k/v store which leads to poor join performance in the current release. Therefore I'd recommend to currently not invest into this.

@nvanbenschoten

This comment has been minimized.

Copy link

nvanbenschoten commented Feb 21, 2018

Cockroachdb's underlying architecture is a k/v store which leads to poor join performance in the current release.

@jensneuse may be referring to https://www.cockroachlabs.com/blog/cockroachdbs-first-join/, which discusses the performance of CockroachDB's join implementation while it was in beta, about a year and a half ago. A lot has changed since then, and CockroachDB now has fully-distributed hash join, merge join, and lookup join implementations.

@vilterp

This comment has been minimized.

Copy link

vilterp commented Apr 25, 2018

@nvanbenschoten tried running Prisma 1.7.1 connecting to Cockroach as if it was Postgres and ran into the following issues:

  • can't create the user-defined function raise_exception, since CRDB doesn't support UDFs (it's unlikely to anytime soon, so will probaby need to do something different on the Prisma side)
  • pg_advisory_lock undefined (we can add this on the CRDB side, even if just as a no-op)
  • CREATE SCHEMA syntax error (CRDB doesn't currently support multiple schemas (docs); we could add that or maybe Prisma could use multiple databases instead…)
@obibring

This comment has been minimized.

Copy link

obibring commented May 4, 2018

Prisma is a dream to work with. The prospect of pairing it with an infinitely scalable DB like Coackroach and AWS Lamba / Zeit now / Apex Up seems like a dream come true from a developers perspective. Would love to see this implemented!

@obibring

This comment has been minimized.

Copy link

obibring commented May 9, 2018

@vilterp, can you confirm this?

@do4gr

This comment has been minimized.

Copy link
Member

do4gr commented May 9, 2018

We could probably work around the user-defined function if need be. We are using it to trigger an exception to roll back transactions. Is there another way to get this effect in CRDB? In MySql we started off with just using a hack (returning several values from a select when only one is allowed) to cause a rollback.

 select case
      when exists( some query )
      then 1
      else (select COLUMN_NAME
      from information_schema.columns
      where table_schema = project)
end

Maybe you have an idea what we could use to get the same effect in CRDB. We basically need the ability to cause a rollback based on the result of a query.

@obibring

This comment has been minimized.

Copy link

obibring commented May 29, 2018

Any updates on this, @nvanbenschoten @vilterp ? I'm about to launch my app in production and would love to do so with Cockroach.

@nvanbenschoten

This comment has been minimized.

Copy link

nvanbenschoten commented May 30, 2018

We basically need the ability to cause a rollback based on the result of a query.

@do4gr CockroachDB has a function called crdb_internal.force_error (documented here) that can be used to force an error. Would this work to accomplish your goal?

@obibring unfortunately I don't know of any updates on our end.

@do4gr

This comment has been minimized.

Copy link
Member

do4gr commented May 31, 2018

Thanks for the answer @nvanbenschoten , as soon as we start looking at a CockroachDB connector I'll see whether that is already enough to make it work.

@flexzuu

This comment has been minimized.

Copy link

flexzuu commented May 31, 2018

Hey folks i got prisma to run on cockroach with some simple changes today. I am not sure what works yet (needs some testing). If someone is interested i can push my fork do Dockerhub.

can't create the user-defined function raise_exception, since CRDB doesn't support UDFs (it's unlikely to anytime soon, so will probaby need to do something different on the Prisma side)

  • I used crdb_internal.force_error as suggested by @nvanbenschoten but i am not sure if it works

pg_advisory_lock undefined (we can add this on the CRDB side, even if just as a no-op)

  • I just made the lock function a noop for now (this is problematic because it will break stuff i don't really know what)

CREATE SCHEMA syntax error (CRDB doesn't currently support multiple schemas (docs); we could add that or maybe Prisma could use multiple databases instead…)

  • I made prisma run as root and created databases instead. An other approach i will test is to just use namespacing in table names.
@vilterp

This comment has been minimized.

Copy link

vilterp commented May 31, 2018

@flexzuu Nice! I'd definitely be interested in seeing this. Were all your changes on the Prisma side?

@flexzuu

This comment has been minimized.

Copy link

flexzuu commented Jun 1, 2018

@vilterp yep all changes where made in the postgresql connector for prisma. I have not looked into make production mode of cockroach work with prisma though (only --insecure for now)

@do4gr

This comment has been minimized.

Copy link
Member

do4gr commented Jun 1, 2018

Hey @flexzuu, that sounds awesome! If you want you can make a PR against our alpha branch. This will trigger our CI and if you rewrote the Postgres Connector we can tell you which tests still fail and maybe help you out with the ones that are broken.

@obibring

This comment has been minimized.

Copy link

obibring commented Aug 22, 2018

Is there any high-level timeline for when work will begin on this? I'd really love to see it land especially since its low hanging fruit!

@gedw99

This comment has been minimized.

Copy link

gedw99 commented Oct 5, 2018

@flexzuu knock knock :)I can help if needed for cockroachdb.

@kylemclaren

This comment has been minimized.

Copy link

kylemclaren commented Nov 11, 2018

Cockroach currently does not support the ENUM type in SQL... would this need to be accounted for?

@obibring

This comment has been minimized.

Copy link

obibring commented Dec 13, 2018

All I want for Christmas is this :(

@adamfeldman-ris

This comment has been minimized.

Copy link

adamfeldman-ris commented Dec 14, 2018

Has anyone tried using prisma introspect against an existing CRDB database? These are the known issues with introspection of Postgres databases: #2377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment