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

chore(electric,client): Create new protocol op to represent a compensation #639

Conversation

magnetised
Copy link
Contributor

For permissions etc we need to always have the OLD values available, so for clarity don't send out SatOpUpdate with no old_data values

Copy link

linear bot commented Nov 8, 2023

VAX-1335 Create new protocol op to represent a compensation

Compensation requests are currently handled by a special SatOpUpdate message with empty old_row_data values. In order to prevent invalid writes (e.g. out of permission boundaries) we need all updates to include both the old and new values

@magnetised magnetised force-pushed the garry/vax-1335-create-new-protocol-op-to-represent-a-compensation branch from 9ac057b to be69b14 Compare November 9, 2023 10:00
@magnetised magnetised force-pushed the garry/vax-1335-create-new-protocol-op-to-represent-a-compensation branch from 6216733 to 439a7cd Compare November 13, 2023 10:21
Copy link
Contributor

@icehaunter icehaunter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, couple tiny questions

@@ -0,0 +1,6 @@
---
"@core/electric": patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a minor on both, since you're introducing a cross-cutting feature that makes new clients incompatible with old server.s

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't sure how we handled the version change now there's no version in the handshake or the protocol

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is, it's just a bit hidden. It's sent in HTTP headers in WebSocket upgrade request.

@@ -167,7 +166,7 @@ function generateCompensationTriggers(table: Table): Statement[] {
1 == (SELECT value from _electric_meta WHERE key == 'compensations')
BEGIN
INSERT INTO _electric_oplog (namespace, tablename, optype, primaryKey, newRow, oldRow, timestamp)
SELECT '${fkTableNamespace}', '${fkTableName}', 'UPDATE', json_object(${joinedFkPKs}), json_object(${joinedFkPKs}), NULL, NULL
SELECT '${fkTableNamespace}', '${fkTableName}', 'COMPENSATION', json_object(${joinedFkPKs}), json_object(${joinedFkPKs}), NULL, NULL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to handle client updates (i.e. reapply these triggers)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we would, good point. off the top of your head, is there a mechanism in place to trigger (😉 ) the re-creation of the triggers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@icehaunter looking at the client it seems that adding re-application of these triggers on boot is a fairly major change. are we comfortable with postponing that feature for the moment considering that this change is backwards compatible with existing trigger implementations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@magnetised magnetised merged commit eb722c9 into main Nov 23, 2023
10 checks passed
@magnetised magnetised deleted the garry/vax-1335-create-new-protocol-op-to-represent-a-compensation branch November 23, 2023 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants