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

feat(subscriptions): Integrate ProduceResult step into executor #2299

Merged
merged 8 commits into from
Jan 7, 2022

Conversation

lynnagara
Copy link
Member

Subscription executor now produces results to the result topic
after executing the ClickHouse query and before committing offsets.
The result topic temporarily comes from either the hardcoded value
or the --override-result-topic flag passed to the CLI to avoid
any chance of writing to the actual result topic that is used
in production currently.

Only execute the scheduled tasks on a topic that match the entity name
passed via the CLI. Also records a metric counting the number of skipped
executions.
Subscription executor now produces results to the result topic
after executing the ClickHouse query and before committing offsets.
The result topic temporarily comes from either the hardcoded value
or the --override-result-topic flag passed to the CLI to avoid
any chance of writing to the actual result topic that is used
in production currently.
@lynnagara lynnagara requested a review from a team as a code owner December 17, 2021 00:52
@lynnagara lynnagara changed the title feat(subscriptions): Integrate ProduceReuslt step into executor feat(subscriptions): Integrate ProduceResult step into executor Dec 17, 2021
@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2021

Codecov Report

Merging #2299 (7283b0a) into master (a676bfb) will increase coverage by 0.02%.
The diff coverage is 79.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2299      +/-   ##
==========================================
+ Coverage   92.73%   92.75%   +0.02%     
==========================================
  Files         559      559              
  Lines       25704    25736      +32     
==========================================
+ Hits        23836    23871      +35     
+ Misses       1868     1865       -3     
Impacted Files Coverage Δ
snuba/cli/subscriptions_executor.py 53.48% <31.25%> (-10.80%) ⬇️
snuba/subscriptions/executor_consumer.py 91.46% <83.33%> (+7.43%) ⬆️
tests/subscriptions/test_executor_consumer.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a676bfb...7283b0a. Read the comment docs.

Copy link
Contributor

@fpacifici fpacifici left a comment

Choose a reason for hiding this comment

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

I think we can make the executor test better to verify that we receive a result, now that you added the producer there.


producer = KafkaProducer(
build_kafka_producer_configuration(
result_topic_spec.topic, override_params={"partitioner": "consistent"},
Copy link
Contributor

Choose a reason for hiding this comment

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

where does this parameter come from ?

Copy link
Contributor

@fpacifici fpacifici Jan 5, 2022

Choose a reason for hiding this comment

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

Ok, it is from the existing subscriptions consumer and it is useful to ensure the same subscription goes to the same partition

@@ -107,8 +110,7 @@ def test_executor_consumer() -> None:

encoded_task = encoder.encode(task)

fut = producer.produce(topic, payload=encoded_task)
fut.result()
producer.produce(scheduled_topic, payload=encoded_task).result()
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we be validating that the query happens, and we have proper results ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Now we do

Base automatically changed from entity-name-filtering to master January 4, 2022 23:51
@fpacifici
Copy link
Contributor

With this I added the test I asked for in the previous review and fixed one bug in the executor consumer

@fpacifici fpacifici requested a review from a team January 5, 2022 22:34
@@ -307,7 +295,6 @@ def submit(self, message: Message[KafkaPayload]) -> None:

def close(self) -> None:
self.__closed = True
self.__next_step.close()
Copy link
Contributor

Choose a reason for hiding this comment

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

This was wrong. The close method should not close the following ones as the partition revoke calls join which can cause messages to be submitted.

Copy link
Member

@evanh evanh left a comment

Choose a reason for hiding this comment

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

LGTM

@fpacifici fpacifici merged commit e41efa4 into master Jan 7, 2022
@fpacifici fpacifici deleted the integrate-produce-result-strategy branch January 7, 2022 18:47
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.

4 participants