-
Notifications
You must be signed in to change notification settings - Fork 962
Support for cockroach db #8662
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
base: master
Are you sure you want to change the base?
Support for cockroach db #8662
Conversation
|
Even if the process starts, error pops up very soon:
UPDATE: I take this back, my cockroach db setup was wrong causing this kind of error, for now it seems that previous commits are enough to run the node with cockroach db |
These notices are printed because all the migrations are executed but in the latest schema none of the primary keys use BIGSERIAL thus this NOTICE is not to be considered |
| ", COALESCE(" | ||
| " (SELECT channel_htlc_id FROM channel_htlcs WHERE id = forwarded_payments.in_htlc_id)," | ||
| " -_ROWID_" | ||
| " -row_number() OVER ()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I think you missed the translation layer?
See devtools/sql-rewrite.py...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that sql-rewrite.py rewrite _ROWID_, but I don't get what is exactly the flow to use it, how do I bootstrap a lightning node with cockroach db?
db/db_postgres.c
Outdated
| size_t actual = PQgetlength(res, stmt->row, col); | ||
|
|
||
| /* CockroachDB returns 8 bytes for INTEGER, PostgreSQL returns 4 */ | ||
| if (actual == 4) { | ||
| be32 bin; | ||
| memcpy(&bin, PQgetvalue(res, stmt->row, col), sizeof(bin)); | ||
| return be32_to_cpu(bin); | ||
| } else if (actual == 8) { | ||
| be64 bin; | ||
| memcpy(&bin, PQgetvalue(res, stmt->row, col), sizeof(bin)); | ||
| return be64_to_cpu(bin); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's super-annoying. Postgres was actually checking our types are correct here (sqlite3 is YOLO), so loosening it is not great.
I wonder if it's best to support a cockroachdb:// db URL, which shares everything except has a different column_int function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a better way to do this, without introducing the specific cockroachdb url.
Using OID, see d584cb9
Cockroach db is a database that ~speaks postgresql on the wire but it's easier to build a cluster with it.
So i thought to try it with the lightning node.
This are the changes needed to run it, I tested this on 25.09 modded with this changes.
The changes are AI generated, I just verified the executable can be launched with those and cockroach db.
Another thing to mention is this notice from the logs is this:
Nov 04 15:03:27 unique lightning-cockroach-start[464556]: NOTICE: using sequential values in a primary key does not perform as well as using random UUIDs. See https://www.cockroachlabs.com/docs/v23.1/serial.html