Skip to content

Add ability to configure timeout for clearing server resources. - #59

Open
P1cheneG wants to merge 1 commit into
mainfrom
add_timeout_setting_for_clearing_server_resources
Open

P1cheneG wants to merge 1 commit into
mainfrom
add_timeout_setting_for_clearing_server_resources

Conversation

@P1cheneG

Copy link
Copy Markdown
Contributor

No description provided.

@P1cheneG
P1cheneG requested a review from RozmiDan November 24, 2026 08:25
@P1cheneG P1cheneG self-assigned this Nov 24, 2026
@P1cheneG P1cheneG added the enhancement New feature or request label Nov 24, 2026
Comment thread fbconn/fbconn.go

// cleanupTimeout returns a timeout for releasing server-side resources after the
// user's request has finished.
func cleanupTimeout() time.Duration {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

getCleanupTimeout()

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Go

Go / code-coverage/gotest

main 3525ff6 add_timeout_setting_... dda87e9 +/-
79% 79% 0%
View coverage of the 9 most impacted files.
File main 3525ff6 add_timeout_setting_... dda87e9 +/-
fbtype/null.go 92% 89% -3%
fbservice/trace_session.go 100% 97% -3%
fbtype/array.go 83% 83% 0%
fbtype/dec16.go 74% 74% 0%
conn.go 85% 85% 0%
fbconn/fbconn.go 78% 79% +1%
fbtype/timetz.go 76% 77% +1%
fbevent/lifecycle.go 78% 80% +2%
internal/cleanu...x/cleanupCtx.go 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@smirnoffjr smirnoffjr added this to the v0.8.0 milestone Nov 24, 2026
Comment thread fbconn/fbconn.go
Comment on lines -3605 to +3617
timeout = 5 * time.Second
timeout = cleanupTimeout()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This timeout is used to enable and disable server cancellation during normal request processing, not just during cleanup. There is already a separate CancelResetTimeout setting. I suggest keeping its five-second default independent from the new cleanup timeout.

// concurrently with driver operations.
// The transmitted timeout must be at least 150 ms.
func SetCleanupTimeout(timeout time.Duration) error {
if timeout >= 150*time.Millisecond {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is the minimum timeout 150 ms? If the driver requires this limit, please explain why. Otherwise, I suggest accepting positive durations, treating zero as the default, and returning an error for negative values.

@@ -0,0 +1,33 @@
package cleanupctx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rename this file to match the naming style used in the project. We don't use camelCase for filenames in this project.

Comment thread fbconn/fbconn.go
// user's request has finished.
func cleanupContext(parent context.Context) (context.Context, context.CancelFunc) {
return context.WithTimeout(context.WithoutCancel(parent), cleanupGracePeriod)
return cleanupctx.CleanupContext(parent)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This helper is also used in Batch.Execute to commit a successful batch in autocommit mode. Changing the cleanup timeout now also changes how long that commit can wait, even though no error has occurred. I suggest keeping the existing five-second timeout for this commit separate from the cleanup setting for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants