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

[yugabyte] Yugabyte compatible implementation #1143

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

barroco
Copy link
Contributor

@barroco barroco commented Jan 2, 2025

This PR introduces the ability to run core-service with a yugabyte datastore.

Key changes:

  1. ybgin indexes on cells have been removed since they don't support to be scanned with other indexes (which is always the case).
  2. SQL query syntax has been changed to be supported by CRDB as well as Yugabyte. No behaviour change is expected.

Note that it was identified that the current implementation may show some failing test runs of the prober with Yugabyte. Current assumption is that the problem is due to default transaction isolation which is not the same in CRDB (Serializable) and Yugabyte (Snapshot). The later may lead to serialization anomalies for single statement queries. Adapting the code to support this specific use case with Yugabyte may require extensive refactoring which may better be addressed in a separate PR.
Prober tests are catching this issue unreliably. It has been kept disabled for Yugabyte until the implementation is stable.

Commits have been organised in order to facilitate the review.

@barroco barroco closed this Jan 2, 2025
@barroco barroco reopened this Jan 2, 2025
@barroco barroco force-pushed the yugabyte-implementation branch 5 times, most recently from 968bb04 to ea1debf Compare January 7, 2025 18:02
@barroco barroco force-pushed the yugabyte-implementation branch from fe834e0 to e735f9a Compare January 14, 2025 14:56
@barroco barroco force-pushed the yugabyte-implementation branch 2 times, most recently from f07f19c to 38dd892 Compare January 21, 2025 17:00
@barroco barroco force-pushed the yugabyte-implementation branch from 4ddbfb2 to 29fc46a Compare January 28, 2025 15:24
@barroco barroco force-pushed the yugabyte-implementation branch from 29fc46a to 6e5a1d0 Compare January 28, 2025 15:39
@barroco barroco force-pushed the yugabyte-implementation branch from 6e5a1d0 to ed79acc Compare January 28, 2025 15:41
@barroco barroco marked this pull request as ready for review January 28, 2025 15:56
Copy link
Contributor

@mickmis mickmis left a comment

Choose a reason for hiding this comment

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

Only minor comments, LGTM otherwise.

dlv --headless --listen=:4000 --api-version=2 --accept-multiclient exec --continue /usr/bin/core-service -- \
-cockroach_host local-dss-crdb \
# Linter is disabled to properly unwrap $DATASTORE_CONNECTION.
# shellcheck disable=SC2086
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -56,7 +61,7 @@ services:
image: interuss-local/dss
entrypoint: /usr/bin/db-manager migrate --schemas_dir=/db-schemas/yugabyte/scd --db_version "latest" --cockroach_host local-dss-ybdb --cockroach_user yugabyte --cockroach_port 5433
depends_on:
local-dss-crdb:
local-dss-ybdb:
Copy link
Contributor

Choose a reason for hiding this comment

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

That was an issue present before already, right?
(nothing to change)

networks:
- dss_sandbox_default_network
healthcheck:
test: wget -O - 'http://localhost/healthy' || exit 1
interval: 3m
start_period: 30s
start_interval: 5s
profiles: ["", "with-yugabyte"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the empty string? Is this supposed to represent 'no profile'?

@@ -87,7 +87,7 @@ func (r *repo) MaxSubscriptionCountInCellsByOwner(ctx context.Context, cells s2.
// strict we could keep this count in memory, (or in some other storage).
var query = `
Copy link
Contributor

Choose a reason for hiding this comment

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

q1 and q2 are added but never used. Are they really necessary for yagabyte?

%s`, constraintFieldsWithoutPrefix, constraintFieldsWithPrefix)
%s`,
constraintFieldsWithoutPrefix,
constraintFieldsWithIndices[0],
Copy link
Contributor

Choose a reason for hiding this comment

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

If those are referenced individually, might as well directly set them in the query, this would be more readable.

@@ -203,7 +228,8 @@ func (c *repo) SearchConstraints(ctx context.Context, v4d *dssmodels.Volume4D) (
COALESCE(starts_at <= $3, true)
AND
COALESCE(ends_at >= $2, true)
LIMIT $4`, constraintFieldsWithoutPrefix)
LIMIT $4;
`, constraintFieldsWithoutPrefix)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is setting a final ; required for yugabyte? If so, why is it not the case of query on scd_constraints and availabilities above? And if not, why adding it here?

scd_operations
(%s)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, transaction_timestamp(), $10, $11, $12, $13)
RETURNING
%s`, operationFieldsWithoutPrefix, operationFieldsWithPrefix)
ON CONFLICT (%s) DO UPDATE
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above: better specify directly the field names if they are referenced individually.

RETURNING
%s`, subscriptionFieldsWithoutPrefix, subscriptionFieldsWithPrefix)
%s`,
subscriptionFieldsWithoutPrefix,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above: better specify directly the field names if they are referenced individually.

Comment on lines +197 to +202
%s = $3::int,
%s = $4,
%s = $5::int,
%s = $6,
%s = $7,
%s = $8::bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is setting the types here required for yugabyte? If so, why is it not required as well for operational intents?

@@ -0,0 +1,2 @@
CREATE INDEX s_cell_idx ON subscriptions USING ybgin (cells);
Copy link
Contributor

Choose a reason for hiding this comment

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

If yugabyte is not deployed anywhere, might as well update v1.0.0 IMO. And it probably makes sense keeping doing so until the v1.0.0 is actually a true working v1 that is released.

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