Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use main DB instead of replica DB for webhook subscriptions (#14482)

Maciej Korycinski201229e99d46
diff --git a/saleor/graphql/webhook/subscription_payload.py b/saleor/graphql/webhook/subscription_payload.py
index 84bb7e3dd1..2b23e29350 100644
--- a/saleor/graphql/webhook/subscription_payload.py
+++ b/saleor/graphql/webhook/subscription_payload.py
@@ -20,7 +20,7 @@ logger = get_task_logger(__name__)
def initialize_request(
requestor=None,
sync_event=False,
- allow_replica=True,
+ allow_replica=False,
event_type: Optional[str] = None,
) -> SaleorContext:
"""Prepare a request object for webhook subscription.
diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py
index 557bd42bf3..3da74606b7 100644
--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py
+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py
@@ -131,7 +131,7 @@ def test_trigger_webhook_sync_with_subscription_within_mutation_use_default_db(
@mock.patch(
"saleor.webhook.transport.asynchronous.transport.generate_payload_from_subscription"
)
-def test_trigger_webhook_async_with_subscription_use_replica_db(
+def test_trigger_webhook_async_with_subscription_use_main_db(
mocked_generate_payload,
mocked_get_webhooks_for_event,
mocked_request,
@@ -168,4 +168,4 @@ def test_trigger_webhook_async_with_subscription_use_replica_db(
# then
mocked_generate_payload.assert_called_once()
- assert mocked_generate_payload.call_args[1]["request"].allow_replica
+ assert not mocked_generate_payload.call_args[1]["request"].allow_replica
diff --git a/saleor/webhook/transport/synchronous/transport.py b/saleor/webhook/transport/synchronous/transport.py
index 8291f376f0..18c6847a1c 100644
--- a/saleor/webhook/transport/synchronous/transport.py
+++ b/saleor/webhook/transport/synchronous/transport.py
@@ -290,7 +290,7 @@ def trigger_all_webhooks_sync(
parse_response: Callable[[Any], Optional[R]],
subscribable_object=None,
requestor=None,
- allow_replica=True,
+ allow_replica=False,
) -> Optional[R]:
"""Send all synchronous webhook request for given event type.