fix: suppress Pulsar C++ client log noise (#936)

Revert consumer receive timeout from 100ms back to the original
2000ms.  The 100ms change was based on a misunderstanding — receive()
is a blocking call that returns immediately when a message arrives,
so the timeout only affects how quickly a consumer checks the shutdown
flag during idle periods.  100ms generated ~200 WARN lines/sec from
the C++ client with no latency benefit.

Also set the Pulsar C++ client logger to Error level so residual
timeout warnings from the subscriber (250ms) don't produce noise.

Update poll timeout test to match reverted 2000ms value
This commit is contained in:
cybermaggedon 2026-05-18 22:08:52 +01:00 committed by GitHub
parent 29d3100c46
commit 47dfc30c1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 10 deletions

View file

@ -272,23 +272,22 @@ class TestMetricsIntegration:
class TestPollTimeout: class TestPollTimeout:
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_poll_timeout_is_100ms(self): async def test_poll_timeout_is_2000ms(self):
"""Consumer receive timeout should be 100ms, not the original 2000ms. """Consumer receive timeout should be 2000ms.
A 2000ms poll timeout means every service adds up to 2s of idle receive() is a blocking call that returns immediately when a
blocking between message bursts. With many sequential hops in a message arrives the timeout only governs how often the loop
query pipeline, this compounds into seconds of unnecessary latency. checks the shutdown flag during idle periods. Lower values
100ms keeps responsiveness high without significant CPU overhead. (e.g. 100ms) generate excessive C++ client WARN logging with
no latency benefit.
""" """
consumer = _make_consumer() consumer = _make_consumer()
# Wire up a mock Pulsar consumer that records the receive kwargs
mock_pulsar_consumer = MagicMock() mock_pulsar_consumer = MagicMock()
received_kwargs = {} received_kwargs = {}
def capture_receive(**kwargs): def capture_receive(**kwargs):
received_kwargs.update(kwargs) received_kwargs.update(kwargs)
# Stop after one call
consumer.running = False consumer.running = False
raise type('Timeout', (Exception,), {})("timeout") raise type('Timeout', (Exception,), {})("timeout")
@ -296,7 +295,7 @@ class TestPollTimeout:
await consumer.consume_from_queue(mock_pulsar_consumer) await consumer.consume_from_queue(mock_pulsar_consumer)
assert received_kwargs.get("timeout_millis") == 100 assert received_kwargs.get("timeout_millis") == 2000
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View file

@ -188,7 +188,7 @@ class Consumer:
try: try:
msg = await loop.run_in_executor( msg = await loop.run_in_executor(
executor, executor,
lambda: consumer.receive(timeout_millis=100), lambda: consumer.receive(timeout_millis=2000),
) )
except Exception as e: except Exception as e:
# Handle timeout from any backend # Handle timeout from any backend

View file

@ -139,6 +139,10 @@ class PulsarBackend:
if api_key: if api_key:
client_args['authentication'] = pulsar.AuthenticationToken(api_key) client_args['authentication'] = pulsar.AuthenticationToken(api_key)
client_args['logger'] = pulsar.ConsoleLogger(
_pulsar.LoggerLevel.Error
)
self.client = pulsar.Client(**client_args) self.client = pulsar.Client(**client_args)
logger.info(f"Pulsar client connected to {host}") logger.info(f"Pulsar client connected to {host}")