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

MPL-68: make run_schemas updates asynchronous #1581

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

lampajr
Copy link
Member

@lampajr lampajr commented Apr 9, 2024

Fixes Issue

Fixes #1579

Changes proposed

Changes:

  • create new channel named schema-sync-{in, out} and related event CreateOrUpdateEvent (TBH I think this could be simplified further as we just need the schemaId value, thus we can remove the event and keep an id only)
  • move newOrUpdatedSchema from ServiceMediator to SchemaServiceImpl for coherence (especially as we need the TxManager)
  • make runService.onNewOrUpdatedSchema(event.id); asynchronous

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a couple of tests, not sure if this is enough but at least it is a start.

Copy link
Member

Choose a reason for hiding this comment

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

Do the tests at least cover the use cases that caused the issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

It depends what you mean by "the issue", because actually the issue (i.e., the timeout) happens only with a large number of runs that we don't have in test environment.
Moreover here we are not actually solving the issue (the timeout), but we are just moving the run_schemas update asynchronously and the tests cover both the creation and update of a Schema, checking if the run_schemas table is eventually updated.

@stalep stalep added this to the 0.13 milestone Apr 9, 2024
Copy link
Member

@stalep stalep left a comment

Choose a reason for hiding this comment

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

looks good!

Copy link
Member

@johnaohara johnaohara left a comment

Choose a reason for hiding this comment

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

There are a couple of areas that I think we need to resolve.

This change also requires changes to production configuration. Ideally we would want an update to an "admin guide" (that we don't have: #1438). I don't think admin is a blocker, but have linked here to reference when we do create an admin guide

Copy link
Member

Choose a reason for hiding this comment

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

Do the tests at least cover the use cases that caused the issue?

@lampajr lampajr force-pushed the MPL-68_on_schema_async branch from d9296e5 to 2a5aa2f Compare April 9, 2024 11:35
@lampajr lampajr requested a review from johnaohara April 9, 2024 11:43
@lampajr
Copy link
Member Author

lampajr commented Apr 10, 2024

As suggested here I added a (timeout) banner notifying the user that run-schema links might not be reflected immediately:
image

I decided to go with a timeout banner rather than a fixed banner (saved in the db) as I think we would like to show that banner only after schema save (and for a limited amount of time).

@lampajr lampajr requested a review from willr3 April 10, 2024 09:09
Copy link
Collaborator

@willr3 willr3 left a comment

Choose a reason for hiding this comment

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

I picked up on mostly minor changes. If the logic works for array run data I assume it will work for object run data but perhaps we should create an explicit test to ensure that also works as expected?

}

@org.junit.jupiter.api.Test
public void testCreateSchemaAfterRun() throws InterruptedException {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we mention that the run is an array run in the test name? The current Horreum implementation handles arrays and json objects in a significantly different manner.
Maybe testCreateSchemaAfterRunUsingArrayData?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah you are right, I created two additional test cases and used a more specific method name for all of them

Util.withTx(tm, () -> {
em.clear();
List<?> runSchemas = em.createNativeQuery("SELECT * FROM run_schemas WHERE runid = ?1").setParameter(1, runId).getResultList();
// two records as the run is an array of two objects, both referencing the same schema
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment escaped the copy, paste, edit :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good spot, fixed

@lampajr
Copy link
Member Author

lampajr commented Apr 10, 2024

With latest commit 5e9e17a I added a couple of tests covering other slightly different use cases as suggested #1581 (review).

If you guys agree on this and this is ready to be merged, I will squash all commits before merging.

@lampajr lampajr requested a review from willr3 April 10, 2024 16:23
@lampajr lampajr self-assigned this Apr 10, 2024
@johnaohara
Copy link
Member

@willr3 please can you review this PR again after the update?

Copy link
Collaborator

@willr3 willr3 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@lampajr
Copy link
Member Author

lampajr commented Apr 15, 2024

Looks good to me

Thanks Will, I am going to squash all commits then

@lampajr lampajr force-pushed the MPL-68_on_schema_async branch from 5e9e17a to e30e650 Compare April 15, 2024 07:24
Copy link
Member

@johnaohara johnaohara left a comment

Choose a reason for hiding this comment

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

LGTM

@johnaohara johnaohara merged commit 80a8af4 into Hyperfoil:master Apr 15, 2024
2 checks passed
Copy link
Collaborator

@willr3 willr3 left a comment

Choose a reason for hiding this comment

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

lgtm

@lampajr lampajr deleted the MPL-68_on_schema_async branch April 16, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GH-1577 / Make processNewOrUpdatedSchema asynchronous
4 participants