RHINENG-25900: grant permissions after pg_repack recreate - #2165
Merged
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates the pg_repack recreation handler to run a small sequence of SQL statements (drop, create, then grant permissions) in order, ensuring the vmaas_sync role regains necessary privileges after the extension is recreated. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Consider executing the
runSequencestatements inside a single database transaction so that a failure in one query doesn’t leave the database in a partially updated state. - It may be helpful to include the failing SQL statement (or a short label for it) in the error response to make operational debugging easier when one of the sequence steps fails.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider executing the `runSequence` statements inside a single database transaction so that a failure in one query doesn’t leave the database in a partially updated state.
- It may be helpful to include the failing SQL statement (or a short label for it) in the error response to make operational debugging easier when one of the sequence steps fails.
## Individual Comments
### Comment 1
<location path="turnpike/controllers/database.go" line_range="32-37" />
<code_context>
}
- if err := database.DB.Exec("CREATE EXTENSION pg_repack").Error; err != nil {
- c.JSON(http.StatusInternalServerError, gin.H{"err": err.Error()})
+ for _, query := range runSequence {
+ if err := database.DB.Exec(query).Error; err != nil {
+ c.JSON(http.StatusInternalServerError, gin.H{"err": err.Error()})
+ return
+ }
</code_context>
<issue_to_address>
**suggestion:** Improve error reporting by indicating which SQL statement in the sequence failed.
As written, the response only returns the raw DB error, which may not make it obvious which statement in `runSequence` failed. Returning the failing query (or a simple label/index for it) alongside the error would significantly aid debugging while preserving the existing control flow.
```suggestion
for index, query := range runSequence {
if err := database.DB.Exec(query).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"err": err.Error(),
"query": query,
"query_index": index,
})
return
}
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2165 +/- ##
==========================================
- Coverage 59.13% 59.07% -0.06%
==========================================
Files 134 134
Lines 8738 8741 +3
==========================================
- Hits 5167 5164 -3
- Misses 3028 3034 +6
Partials 543 543
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Secure Coding Practices Checklist GitHub Link
Secure Coding Checklist
Summary by Sourcery
Update the pg_repack recreation endpoint to also restore required permissions after recreating the extension.
Bug Fixes:
Enhancements: