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

21.1 multi-region #27

Merged
merged 2 commits into from
Apr 27, 2021
Merged

21.1 multi-region #27

merged 2 commits into from
Apr 27, 2021

Conversation

ericharmeling
Copy link
Contributor

@ericharmeling ericharmeling commented Apr 23, 2021

Fixes #25.
Fixes #4.

@ericharmeling
Copy link
Contributor Author

@otan, @rmloveland - added y'all as reviewers, but no rush/feel free to pass to someone else.

I think the main thing I need reviewed is dbinit.sql. But feel free to comment on the other changes as well.

dbinit.sql Outdated
;
CONSTRAINT fk_city_ref_users FOREIGN KEY (rider_id) REFERENCES users(id),
CONSTRAINT fk_vehicle_ref_vehicles FOREIGN KEY (vehicle_id) REFERENCES vehicles(id)
);
Copy link

Choose a reason for hiding this comment

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

nit: unindent ending );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After fixing the table (see comment below), I formatted the document with pgformatter. Should look nicer all over now.

dbinit.sql Outdated
);


ALTER TABLE rides ADD COLUMN region crdb_internal_region AS (
Copy link

Choose a reason for hiding this comment

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

do we ever make this table REGIONAL BY ROW? seems like it is REGIONAL BY TABLE at the moment.
we should do this inline, i.e.

CREATE TABLE users (

   ...,
   region crdb_internal_region  CASE WHEN city = 'amsterdam' THEN 'gcp-europe-west1'
       WHEN city = 'paris' THEN 'gcp-europe-west1'
       WHEN city = 'rome' THEN 'gcp-europe-west1'
       WHEN city = 'new york' THEN 'gcp-us-east1'
       WHEN city = 'boston' THEN 'gcp-us-east1'
       WHEN city = 'washington dc' THEN 'gcp-us-east1'
       WHEN city = 'san francisco' THEN 'gcp-us-west1'
       WHEN city = 'seattle' THEN 'gcp-us-west1'
       WHEN city = 'los angeles' THEN 'gcp-us-west1'
       ELSE 'gcp-us-east1',
     
       ....
) LOCALITY REGIONAL BY ROW; -- optionally REGIONAL BY ROW AS "region"

same with the others

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My mistake. Fixed for rides.

Also, moved the region column definition to the CREATE TABLE statement for all tables.

dbinit.sql Outdated
@@ -4,130 +4,97 @@ SET sql_safe_updates = false;
DROP DATABASE IF EXISTS movr CASCADE;


CREATE DATABASE movr;
CREATE DATABASE movr PRIMARY REGION "gcp-us-east1" REGIONS "gcp-europe-west1", "gcp-us-west1";
Copy link

Choose a reason for hiding this comment

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

the problem with this setup is that users have to ensure they set up the servers correctly, i.e. set --locality=region=<blah> in their flask setup. is that what we want / already have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah ... the README and tutorial specifically instruct the user to specify the localities that match these region names. They are based on the GCP cluster names. On CC, the localities for a multi-region GCP cluster should match these names anyways.

@ericharmeling
Copy link
Contributor Author

TFTR @otan !

Copy link

@rmloveland rmloveland left a comment

Choose a reason for hiding this comment

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

LGTM

As far as I understand what is happening here, is the summary basically the following?

  1. Update to use the new multi-region SQL abstractions instead of those yucky partitioning stmts
  2. Use a version of movr underneath that does not have the compound PK on (city, id)

@ericharmeling
Copy link
Contributor Author

TFTR @rmloveland !

  1. Update to use the new multi-region SQL abstractions instead of those yucky partitioning stmts
  2. Use a version of movr underneath that does not have the compound PK on (city, id)

Exactly. I also snuck in the fixed cockroach demo port in the .env and README.

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.

v21.1 Multi-region Updates Bump down partition locality from city to region
3 participants