Skip to content
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

fix(ingestion/bigquery): user exceeded quota for concurrent project.lists requests #10578

Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6385a63
add Bigquery list projects rate limit
shubhamjagtap639 May 23, 2024
fc9a8cc
Address review comments
shubhamjagtap639 May 24, 2024
58194de
Modify comment
shubhamjagtap639 May 24, 2024
1bb7819
Merge branch 'master' into bigquery-project.lists-requests-quota-exce…
hsheth2 May 24, 2024
bcedaf5
Add rate limiter for bq client list projects request
shubhamjagtap639 May 27, 2024
18e3b90
Revert test case changes
shubhamjagtap639 May 27, 2024
8061a37
Modify ratelimiter code and reduce the max result of list project api
shubhamjagtap639 May 28, 2024
206a123
Modify the max result and page size in bq client list project
shubhamjagtap639 May 30, 2024
9fa2318
temporary debug changes
shubhamjagtap639 Jun 5, 2024
02b69a0
Temporary debug changes
shubhamjagtap639 Jun 5, 2024
6fc9842
Add retry to bq client list project api
shubhamjagtap639 Jun 5, 2024
f4f7388
Modify bq get project method
shubhamjagtap639 Jun 11, 2024
31eece4
Modify bq get project method
shubhamjagtap639 Jun 11, 2024
29a22a6
Add debug log in bg list project request
shubhamjagtap639 Jun 11, 2024
28b4a6e
Add back retry to bq client list project request
shubhamjagtap639 Jun 11, 2024
be8a63c
Revert the get_projects method and add retry in list project request
shubhamjagtap639 Jun 12, 2024
a8bb758
Modify get_project method and list project count in report
shubhamjagtap639 Jun 12, 2024
ae42a79
Modify comment in get_project method
shubhamjagtap639 Jun 12, 2024
a685b27
Merge branch 'master' into bigquery-project.lists-requests-quota-exce…
hsheth2 Jun 14, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

@dataclass
class BigQuerySchemaApiPerfReport(Report):
num_list_projects: int = 0
num_list_projects_retry_request: int = 0
list_projects: PerfTimer = field(default_factory=PerfTimer)
list_datasets: PerfTimer = field(default_factory=PerfTimer)
get_columns_for_dataset: PerfTimer = field(default_factory=PerfTimer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import datetime, timezone
from typing import Any, Dict, Iterator, List, Optional

from google.api_core import retry
from google.cloud import bigquery
from google.cloud.bigquery.table import (
RowIterator,
Expand Down Expand Up @@ -148,14 +149,33 @@ def get_query_result(self, query: str) -> RowIterator:
return resp.result()

def get_projects(self) -> List[BigqueryProject]:
def _should_retry(exc: BaseException) -> bool:
logger.debug(
f"Exception occured for project.list api. Reason: {exc}. Retrying api request..."
)
self.report.num_list_projects_retry_request += 1
return True

with self.report.list_projects:
try:
projects = self.bq_client.list_projects()

return [
# Bigquery API has limit in calling project.list request i.e. 2 request per second.
# https://cloud.google.com/bigquery/quotas#api_request_quotas
# Whenever this limit reached an exception occur with msg
# 'Quota exceeded: Your user exceeded quota for concurrent project.lists requests.'
# Hence, added the api request retry of 15 min.
# We already tried adding rate_limit externally, proving max_result and page_size
# to restrict the request calls inside list_project but issue still occured.
projects_iterator = self.bq_client.list_projects(
retry=retry.Retry(
predicate=_should_retry, initial=10, maximum=180, timeout=900
)
)
projects: List[BigqueryProject] = [
BigqueryProject(id=p.project_id, name=p.friendly_name)
for p in projects
for p in projects_iterator
]
self.report.num_list_projects = len(projects)
return projects
except Exception as e:
logger.error(f"Error getting projects. {e}", exc_info=True)
return []
Expand Down
Loading