Skip to content

Commit

Permalink
fix(ingest/gc): infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
anshbansal committed Jan 16, 2025
1 parent 2226820 commit 95036fc
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class SoftDeletedEntitiesCleanupConfig(ConfigModel):

@dataclass
class SoftDeletedEntitiesReport(SourceReport):
num_calls_made: Dict[str, int] = field(default_factory=dict)
num_entities_found: Dict[str, int] = field(default_factory=dict)
num_soft_deleted_entity_processed: int = 0
num_soft_deleted_retained_due_to_age: int = 0
Expand Down Expand Up @@ -242,6 +243,11 @@ def _get_soft_deleted(self, graphql_query: str, entity_type: str) -> Iterable[st

while True:
try:
if entity_type not in self.report.num_calls_made:
self.report.num_calls_made[entity_type] = 1

Check warning on line 247 in metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py#L246-L247

Added lines #L246 - L247 were not covered by tests
else:
self.report.num_calls_made[entity_type] += 1
self._print_report()

Check warning on line 250 in metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py#L249-L250

Added lines #L249 - L250 were not covered by tests
result = self.ctx.graph.execute_graphql(
graphql_query,
{
Expand Down Expand Up @@ -272,6 +278,9 @@ def _get_soft_deleted(self, graphql_query: str, entity_type: str) -> Iterable[st
scroll_across_entities = result.get("scrollAcrossEntities")
if not scroll_across_entities or not scroll_across_entities.get("count"):
break
search_results = scroll_across_entities.get("searchResults")
if not search_results:
break

Check warning on line 283 in metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py#L281-L283

Added lines #L281 - L283 were not covered by tests
if entity_type == "DATA_PROCESS_INSTANCE":
# Temp workaround. See note in beginning of the function
# We make the batch size = config after call has succeeded once
Expand All @@ -282,7 +291,7 @@ def _get_soft_deleted(self, graphql_query: str, entity_type: str) -> Iterable[st
self.report.num_entities_found[entity_type] += scroll_across_entities.get(
"count"
)
for query in scroll_across_entities.get("searchResults"):
for query in search_results:

Check warning on line 294 in metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py#L294

Added line #L294 was not covered by tests
yield query["entity"]["urn"]

def _get_urns(self) -> Iterable[str]:
Expand Down

0 comments on commit 95036fc

Please sign in to comment.