Skip to content

Conversation

mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Jul 21, 2025

Description

to avoid failed to initialize database: resource temporarily unavailable when node restart without waiting for gracefully shutdown

Closes: #319


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

Reviewers Checklist

All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

to avoid failed to initialize database: resource temporarily unavailable
@mmsqe mmsqe requested review from a team as code owners July 21, 2025 06:32
@mmsqe mmsqe marked this pull request as draft July 21, 2025 06:59
@mmsqe mmsqe marked this pull request as ready for review July 21, 2025 11:54
@mmsqe mmsqe changed the title fix: no app.Close to cleanup resource on graceful shutdown fix: wait for graceful shutdown before restart Jul 21, 2025
@aljo242
Copy link
Contributor

aljo242 commented Jul 21, 2025

@mmsqe can you please link an existing github issue for this? If one does not exist, feel free to create one. We want to ensure that all PRs have an associated issue for context.

@aljo242
Copy link
Contributor

aljo242 commented Jul 28, 2025

@aljo242 to review sometime

@aljo242 aljo242 self-assigned this Jul 28, 2025
}
return nil

case err := <-errCh:
if err == http.ErrServerClosed {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we still return nil from here and not log "closed" as an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

excluded

Comment on lines +229 to +231
var app types.Application
defer func() {
if err := db.Close(); err != nil {
svrCtx.Logger.Error("error closing db", "error", err.Error())
if app == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this always be true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

handle db close if app not initiated when openTraceWriter fail

if err != nil {

Comment on lines +330 to +332
var app types.Application
defer func() {
if err := db.Close(); err != nil {
svrCtx.Logger.With("error", err).Error("error closing db")
if app == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor

@aljo242 aljo242 left a comment

Choose a reason for hiding this comment

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

@mmsqe left comments

@aljo242 aljo242 added this pull request to the merge queue Aug 6, 2025
Merged via the queue into cosmos:main with commit b0e5228 Aug 6, 2025
16 checks passed
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.

[Bug]: node restart without waiting for graceful shutdown
2 participants