Skip to content

adding context timeouts for management queries based on reload interval#390

Draft
rasamala83 wants to merge 7 commits intopaypal:mainfrom
rasamala83:adding_timeout_management_queries
Draft

adding context timeouts for management queries based on reload interval#390
rasamala83 wants to merge 7 commits intopaypal:mainfrom
rasamala83:adding_timeout_management_queries

Conversation

@rasamala83
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread lib/racmaint.go Outdated
return
case <-timeTicker.C:
//Periodic data loading
racMaint(&ctx, shard, db, racSQL, cmdLineModuleName, prev, waitTime/2)
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.

Let us use a configurable query timeout for maintenance queries. Here, the wait time could vary across pools.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread lib/racmaint.go Outdated
//First time data loading
racMaint(&ctx, shard, db, racSQL, cmdLineModuleName, prev, waitTime/2)

timeTicker := time.NewTicker(waitTime)
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.

defer timeTicker.Stop() to release resources.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed timeTicker.Stop() and reset

Comment thread lib/racmaint.go
case <-ctx.Done():
logger.GetLogger().Log(logger.Alert, "Application main context has been closed, so exiting from racmaint data reload.")
return
case <-timeTicker.C:
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.

I'm fine with this but why do we need to introduce the timeTicker? I feel the existing code is simpler.

Comment thread lib/shardingcfg.go Outdated
db, err = openDb(shard)
if err == nil {
err = loadMap(ctx, db)
err = loadMap(&ctx, db, reloadInterval/2)
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.

Same as above. Let us use a configurable query timeout for maintenance queries

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread lib/shardingcfg.go
loadWhitelist(&ctx, db, reloadInterval/2)
}
go func() {
reloadTimer := time.NewTimer(reloadInterval) //Periodic reload timer
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.

This needs to be replaced with NewTicker as the timer fires just once.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

added reset and clean up options for timer

Comment thread lib/shardingcfg.go
if err == nil {
err = loadMap(ctx, db)
select {
case <-ctx.Done():
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.

Let us also add timeout-related tests for validation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

added tests.

@venkatsridhar95
Copy link
Copy Markdown
Collaborator

@rasamala83 Converting the PR to draft as it is work in progress.

@venkatsridhar95 venkatsridhar95 marked this pull request as draft May 15, 2024 21:06
@venkatsridhar95 venkatsridhar95 force-pushed the main branch 2 times, most recently from cd1c2cb to 7fd4baa Compare March 5, 2025 11:58
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.

3 participants