Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: remove parallel queries in the same transaction #18489

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

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Jun 23, 2025

Parallel concurrent queries cannot be run in the same tx

Was getting this error: https://stackoverflow.com/questions/78472996/go-postgres-pq-unexpected-parse-response-c-with-queryrow

Copy link
Member Author

Emyrk commented Jun 23, 2025

@Emyrk Emyrk marked this pull request as ready for review June 23, 2025 01:40
@Emyrk Emyrk changed the base branch from stevenmasley/parameters_to_preview to graphite-base/18489 June 23, 2025 05:12
@Emyrk Emyrk force-pushed the stevenmasley/sequential_query branch from 077e337 to a7699f5 Compare June 23, 2025 05:13
@Emyrk Emyrk changed the base branch from graphite-base/18489 to stevenmasley/deadlock_fetch June 23, 2025 05:13
@Emyrk Emyrk requested a review from aslilac June 23, 2025 06:07
@Emyrk Emyrk force-pushed the stevenmasley/deadlock_fetch branch from 2a37b9b to a33fad3 Compare June 23, 2025 06:07
@Emyrk Emyrk force-pushed the stevenmasley/sequential_query branch from a7699f5 to f861c42 Compare June 23, 2025 06:07
@Emyrk Emyrk requested a review from Copilot June 23, 2025 12:25
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the use of parallel queries within a single transaction to avoid concurrent query issues with PostgreSQL. It refactors query execution to run sequentially with updated error wrapping for clarity.

  • Removed the use of errgroup for concurrent query execution.
  • Updated error handling with xerrors.Errorf wrappers.
  • Refactored variable declarations for query results.
Comments suppressed due to low confidence (3)

coderd/dynamicparameters/render.go:323

  • The variable 'key' is used outside of its declaration block, making it unavailable when constructing the WorkspaceOwner struct. Consider declaring 'key' in the outer scope before its assignment so that its value can be properly accessed later.
		SSHPublicKey: key.PublicKey,

coderd/dynamicparameters/render.go:311

  • The 'groupNames' variable is declared locally using a short declaration, which may limit its scope. It should be declared in the outer scope to ensure it is accessible when constructing the WorkspaceOwner struct.
	groupNames := make([]string, 0, len(groups))

coderd/dynamicparameters/render.go:277

  • The 'ownerRoles' variable is being declared with a short assignment inside a block, which may restrict its scope and lead to a runtime error when accessed later. Consider declaring it in an outer scope so that it remains accessible when needed.
	ownerRoles := make([]previewtypes.WorkspaceOwnerRBACRole, 0, len(roles))

@Emyrk Emyrk force-pushed the stevenmasley/deadlock_fetch branch 2 times, most recently from 7349e1f to 043cd58 Compare June 23, 2025 16:32
@Emyrk Emyrk force-pushed the stevenmasley/sequential_query branch from 1d27539 to ac9d0e6 Compare June 23, 2025 16:32
@Emyrk Emyrk force-pushed the stevenmasley/deadlock_fetch branch from 043cd58 to 37c71f1 Compare June 23, 2025 16:45
@Emyrk Emyrk force-pushed the stevenmasley/sequential_query branch from ac9d0e6 to 6b4dabf Compare June 23, 2025 16:45
@Emyrk Emyrk changed the base branch from stevenmasley/deadlock_fetch to graphite-base/18489 June 23, 2025 16:58
@Emyrk Emyrk force-pushed the stevenmasley/sequential_query branch from 6b4dabf to 1e1cb20 Compare June 23, 2025 16:59
@Emyrk Emyrk force-pushed the graphite-base/18489 branch from 37c71f1 to c1b35bf Compare June 23, 2025 16:59
@graphite-app graphite-app bot changed the base branch from graphite-base/18489 to main June 23, 2025 16:59
@Emyrk Emyrk force-pushed the stevenmasley/sequential_query branch from 1e1cb20 to cb43418 Compare June 23, 2025 16:59
Parallel concurrent queries cannot be run in the same tx
@Emyrk Emyrk force-pushed the stevenmasley/sequential_query branch from cb43418 to a908ce6 Compare June 23, 2025 17:04
@Emyrk Emyrk merged commit 7254c08 into main Jun 23, 2025
35 checks passed
@Emyrk Emyrk deleted the stevenmasley/sequential_query branch June 23, 2025 17:18
@github-actions github-actions bot locked and limited conversation to collaborators Jun 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants