Skip to content

Commit

Permalink
update the scheduler of update_tidb_serverless_status_task to 1/10min (
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnJyong authored Nov 27, 2024
1 parent 33d6d26 commit 41c6bf5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
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

0 comments on commit 41c6bf5

Please sign in to comment.