Skip to content

update the scheduler of update_tidb_serverless_status_task to 1/10min #11135

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
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/extensions/ext_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __call__(self, *args: object, **kwargs: object) -> object:
},
"update_tidb_serverless_status_task": {
"task": "schedule.update_tidb_serverless_status_task.update_tidb_serverless_status_task",
"schedule": crontab(minute="30", hour="*"),
"schedule": timedelta(minutes=10),
},
"clean_messages": {
"task": "schedule.clean_messages.clean_messages",
Expand Down
27 changes: 12 additions & 15 deletions api/schedule/update_tidb_serverless_status_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,18 @@
def update_tidb_serverless_status_task():
click.echo(click.style("Update tidb serverless status task.", fg="green"))
start_at = time.perf_counter()
while True:
try:
# check the number of idle tidb serverless
tidb_serverless_list = TidbAuthBinding.query.filter(
TidbAuthBinding.active == False, TidbAuthBinding.status == "CREATING"
).all()
if len(tidb_serverless_list) == 0:
break
# update tidb serverless status
iterations_per_thread = 20
update_clusters(tidb_serverless_list)

except Exception as e:
click.echo(click.style(f"Error: {e}", fg="red"))
break
try:
# check the number of idle tidb serverless
tidb_serverless_list = TidbAuthBinding.query.filter(
TidbAuthBinding.active == False, TidbAuthBinding.status == "CREATING"
).all()
if len(tidb_serverless_list) == 0:
return
# update tidb serverless status
update_clusters(tidb_serverless_list)

except Exception as e:
click.echo(click.style(f"Error: {e}", fg="red"))

end_at = time.perf_counter()
click.echo(
Expand Down