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

Feature/741 b prisma transactions #779

Closed
wants to merge 11 commits into from

Conversation

Kasshern
Copy link
Collaborator

@Kasshern Kasshern commented Jan 11, 2024

Description

Implements prototype for prisma service atomic execution of db operations.

Related Issue

SRI - Introduce Prisma Transactions #741

Motivation and Context

links Db operations atomically

How Has This Been Tested

tests forthcoming

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Request to be added as a Code Owner/Maintainer

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I commit to abide by the Responsibilities of Code Owners/Maintainers.

…torage agents, deletes storage agent extension of prismaService.
…nd converts POC prisma actions into prisma promises within respective storage agents
…and accept and await spread operator operations
…torage agents, and make sure of closures in passing arguments to prisma service execute transaction
…torage agents, deletes storage agent extension of prismaService.
…nd converts POC prisma actions into prisma promises within respective storage agents
…and accept and await spread operator operations
…torage agents, and make sure of closures in passing arguments to prisma service execute transaction
bpiAccountCandidate: BpiAccount,
workflowCandidate: Workflow,
): Promise<any> {
const boundStoreNewWorkflow = this.storeNewWorkflow.bind(this);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why binding this here?

this.bpiAccountStorageAgent.storeNewBpiAccount.bind(
this.bpiAccountStorageAgent,
);
const results = await this.prisma.executeTransaction(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you are still passing only one operation here, so not quite showing array of sequential operations, it should be array [storeBpiAccount, storeWorkflow], not storeBpiAccount.then(storeWorkflow)? this way it seems we are controlling this execution, and prisma should sequentially execute all or nothing behind the scenes if i understand correctly

@@ -49,14 +53,14 @@ export class WorkflowStorageAgent {
});
}

async storeNewWorkflow(workflow: Workflow): Promise<Workflow> {
storeNewWorkflow(workflow: Workflow): PrismaPromise<WorkflowModel> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure i understand changes to this method, could you please add more details?

return await this.$transaction(async () => {
const results: any[] = [];
for (const operation of operations) {
results.push(await operation());
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need to await operations?

@ognjenkurtic
Copy link
Collaborator

@Kasshern could we go through this in detail on Monday? would like to get a walk through to be able to better understand some of the decisions made. Or provide async here a little more details please explaining the implementation decisions

@ognjenkurtic
Copy link
Collaborator

Agreement is to stick with the simple nested query approach for now in few places where we care about transactions until we find a better way to solve this

@Ybittan
Copy link
Member

Ybittan commented Feb 5, 2024

Core Dev 02/05/24 - This PR will be replaced with a more simple implementation.

@Ybittan Ybittan closed this Feb 5, 2024
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.

4 participants