Skip to content

Plugin model - #1045

Merged
vigoo merged 45 commits into
mainfrom
vigoo/plugin-model
Nov 21, 2024
Merged

Plugin model#1045
vigoo merged 45 commits into
mainfrom
vigoo/plugin-model

Conversation

@vigoo

@vigoo vigoo commented Oct 30, 2024

Copy link
Copy Markdown
Contributor

Resolves #1034

@noise64 noise64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added a few DB related comments and questions, let's disccuss them in more detail IRL

Comment thread golem-component-service/db/migration/postgres/005__add_plugins.sql
component_id uuid REFERENCES components (component_id),
component_version bigint,

FOREIGN KEY (plugin_name, plugin_version) REFERENCES plugins (name, version)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Foreign keys are not enforced or enabled by default, it is required to be configured on each open (and missing to do so can create a db with integrity problems). I think we do not have such option in our sqlite config currenlty and it not set by default.

Also there are a few things that worth to be checked (see https://www.sqlite.org/foreignkeys.html), like the foreign key must reference a fields in a way that matches a primary or unique key in the referenced table. This seems to be the case here, just wanted to highlight that indexes are not auto created for such uses, unlike other DBs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So what do I do? :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As discussed, will be done in an followup PR

transform_url text,
component_id uuid REFERENCES components (component_id),
component_version bigint,
deleted boolean NOT NULL DEFAULT FALSE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it seems that we do need to use this in almost every query, so i would add a covering index for the primary key columns and this together

let namespace: String = result.get("namespace");
let name: String = result.get("name");
if namespace != component.namespace || name != component.name {
transaction.rollback().await?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a higher level transaction construct in sqlx? manually doing the rollbacks on errors seems fragile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would change this select to be part of the insert (or rather, an upsert, and check if there were any affected rows, otherwise i think there are some race conditions here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It should be rolled back on drop, my tests indicated that it is was not working properly, and adding an explicit rollback fixed the test. I don't like it either.

) -> Result<ComponentRecord, RepoError> {
let mut transaction = self.db_pool.begin().await?;

let result = sqlx::query("SELECT namespace FROM components WHERE component_id = $1")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i would probably make this part of the update through a join, and make them a predicate.
As for the "WITH prev selects", i think those are not reliable at all without golding explicit locks for the affected rows (or use a pattern where before any component version changes we do a single row lock on the components table)

@vigoo
vigoo marked this pull request as ready for review November 20, 2024 20:52
@vigoo vigoo changed the title Plugin model (WIP) Plugin model Nov 21, 2024
@vigoo
vigoo merged commit 255f886 into main Nov 21, 2024
@vigoo
vigoo deleted the vigoo/plugin-model branch November 21, 2024 17:15
vigoo added a commit that referenced this pull request Aug 15, 2025
* Initial plugin model and REST API

* Plugins CLI first steps

* More CLI work

* CLI implementation and REST API fixes

* Fixes and refactorings regarding component service's repo tests

* Further test refactorings

* test_default_plugin_repo

* Tests and fixes for the plugin repos

* gRPC API, changes

* Plugin installation repo actions moved to component repo transactions WIP

* Plugin installation repo actions moved to component repo transactions

* Rewired plugin service

* Intermediate state of redesignin the component repo

* Switched to ComponentOwner from Namespace in component-service

* Introduced component version available flag

* Moved namespace filtering to SQL

* Decoupled object store entity from component version, WIP

* Decoupled object store entity from component version

* gRPC implementation

* Plugin scope request context

* Separate plugin owner vs component owner abstraction

* Changed accessible scope interface

* Extra error case

* Moved UpdatePayload to base

* pub

* Fixes

* Refactoring to make some plugin types more reusable

* Further refactoring to share plugin installation queries

* PluginOwner moved to common

* Connection between component owner and plugin owner

* Fix

* Fix

* Update serde_json_path

* Made some gRPC helper functions public

* Namespace to the worker request executor

* Removed unused auth context parameters

* Removed auth context completely from the worker service trait

* Exposed function in cli

* Exposed some more functions in cli

* Reusing InitialComponentFile from model in golem-client

* Fix

* Fix
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.

Plugin model

2 participants