-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support Google Cloud Spanner #717
Comments
Cloud Spanner now supports a Postgres interface (In preview) |
I'd love to see Spanner supported. Now that Spanner has granular instance sizing and cloud sql has mandatory downtime where Spanner doesn't, it makes it the preferred database over cloudsql. Spanner is starting to rollout a postgres dialect to spanner. They mention it's not 100% compatible but it would be great have prisma add some documentation outlining limitations if any |
Nice. (Note that the following does not indicate that we are committed to build a Google Spanner compatible connector any time soon. This is just me exploring and figuring out what might already work, and what does not. If Prisma will ever have this, and wants to spend more time on this, will be decided on a different level. I am just curious.) Our next steps here would be...
So if you understand GCP well, have a Spanner instance with data and the PostgreSQL interface enabled - please try these steps! (And/or send me an email at jan@prisma.io and send over the connection string, so we can do so at the side). |
Tried to use PGAdapter and Spanner Emulator locally with Prisma using the following docker-compose file: version: "3.3"
services:
spanner:
env_file: .env
image: gcr.io/cloud-spanner-emulator/emulator
ports:
- '9010:9010'
- '9020:9020'
pg-adapter:
image: gcr.io/cloud-spanner-pg-adapter/pgadapter:v0.6.1
volumes:
- ./test/fake-spanner-credentials.json:/acct_credentials.json
ports:
- 127.0.0.1:5432:5432
command:
- -p my_project
- -i my_instance
- -d my_database
- -c /acct_credentials.json
- -x Getting this error:
So the problem is that PGAdapter requires connection url to start with Using Using |
Adding an env var that allows |
If there is no further validation for the rest of connection url: |
Thanks for clarifying that, we would indeed probably check for port and so on. So they way here would be to accept a completely different connection string. Interesting that |
Now that I think about which url would be okay for PGAdapter to work I am kinda lost, as it requires cloudspanner prefix and after that you would need to point to a local IP and port. So theoretically it should be comething like But there is a big chance that it wont work like that as PGAdapter docs say that only |
Has there been any updates / further thoughts on this @janpio? Prisma should seriously consider attempting to support a Spanner connector. The PostgreSQL interface for Cloud Spanner is now in GA and their basic pricing tier has dropped down to as low as $40/month. Having a cheap, strongly consistent cross-region, ACID compliant, relational database is basically the holy grail, but unfortunately, many fast-moving teams will either overlook or avoid using Spanner because there is no Type-safe Node ORM that connects to it (despite the efforts by Google to provide the PostgreSQL Interface). By supporting Spanner, Prisma has the opportunity to capture the market of large enterprise companies who use and/or want to use it with Node. This could then be leveraged as a funnel to drive these large customers towards your paid and enterprise offerings, which pays off the effort spent integrating Spanner. |
This is currently not a priority for us. If someone (@glebbash?) confirms that for example allowing |
Hello, I have setup a Spanner instance, with the When starting my app, I get the following error: I use Plus the following Docker container, |
Naive question, what is the quickest way to setup up the required |
Edit: Update from the PGAdapter maintainer: GoogleCloudPlatform/pgadapter#581
It seems as though I'm too unfamiliar with Prisma's internals to try remove the statement myself to proceed. I just tried the same thing as @etifontaine and got the same result. To reproduce the error, follow these steps to set up the following:
You don't need to run PGAdapter in Debug mode. I have included the output at the bottom
I also got the same error when trying with a simple migrate
PGAdapter Debug Logs
|
Awesome. I responded on that issue - let's see if we can figure this out together to move forward here. |
Some experimental work started over there: GoogleCloudPlatform/pgadapter#589 + GoogleCloudPlatform/pgadapter#590 <3 |
I'll add my two cents here - it would actually be nice to have a spanner native (non-postgres dialect) version. There are a few really interesting caveats to the way the postgres dialect works as have been noted in this thread. First, you have to run a separate process (the pgadapter) to do the translation, but secondly, there are actually some really important features missing when you use the postgres dialect - specifically, the change log that spanner produces and is consumable for CDC doesn't work with postgres (as I understand it). I also remember the journey we went through here for cockroach where, even though it said wire compatible, there are enough special things that prisma does that it didn't really work perfectly until there was a full, flavored release. |
We fundamentally agree, but to explain why I am pushing on this: Native Spanner support is not happening for sure this year. If it turns out that the PgAdapter is close enough or can be adapted though, we could possibly find a way to make this usable sooner. |
@janpio PGAdapter has been updated to version 15. I have re-tried the basic query and it worked as expected. const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient();
(async () => {
const result = await prisma.$queryRaw`SELECT 1 as hello_world`
console.log(result)
})() Now produces the following as expected. [ { hello_world: 1n } ] // 1n is a bigint Before you throw the PG test suite at the Adapter to check compatibility, I have already tested basic migrations and found the next blocker. When attempting to migrate the database with the following schema //schema.prisma
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
name String
} I received the following error when calling
This error is also thrown when directly querying the How should we proceed? Is this something that should be handled upstream by PGAdapter? Or should it be handled by Prisma? Once we decide, then we can re-engage Knut Olav Løite for possible fixes. |
I think (We could rewrite our code to handle this not being present, but for normal PostgreSQL (and compatible databases) that is never expected to fail, so would be a bit weird - but we most probably could: https://github.com/prisma/prisma-engines/blob/af46365b40aa4864b99acec97dc2dd5bdc27411c/migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs#L562-L594) I expect a few more of these to pop up on |
I've mentioned this on the prisma support issue: GoogleCloudPlatform/pgadapter#589 |
im running into similar errors when using pgadapter with prisma migrate
|
Hello everyone, do you have any update on the Spanner support? Has anybody been able to make it work reliably with Prisma? 🙇♂️ |
We recently tried to use Spanner as a Prisma backend but gave it up in the end. If I remember correctly, we couldn't make migrations work properly without more work than it was worth. I'd love to hear if and how anyone got this to work properly |
Hey! :)
It would be awesome if Prisma Client could be compatible with https://cloud.google.com/spanner/
The text was updated successfully, but these errors were encountered: