Skip to content

Commit 48c47e4

Browse files
authored
ref: Add extra logging for debugging commits (#302)
There is a mystery right now which is causing (probably) very old commit messages to still be present. This seems to be the case even after we switched the cleanup policy on the topic to `compact,delete` from `compact` so that messages eventually expire (they previously never expired). This adds some logging to help us figure out where/when these old messages came from and helps us determine when the legacy decoder can be safely removed.
1 parent 9301e0f commit 48c47e4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

arroyo/backends/kafka/commit.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
from datetime import datetime
34

45
from arroyo.backends.kafka import KafkaPayload
@@ -10,6 +11,10 @@
1011
# remove in a future release of Arroyo
1112
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
1213

14+
logger = logging.getLogger(__name__)
15+
16+
max_times_to_log_legacy_message = 10
17+
1318

1419
class CommitCodec(Codec[KafkaPayload, Commit]):
1520
def encode(self, value: Commit) -> KafkaPayload:
@@ -65,6 +70,7 @@ def decode(self, value: KafkaPayload) -> Commit:
6570
)
6671

6772
def decode_legacy(self, value: KafkaPayload) -> Commit:
73+
global max_times_to_log_legacy_message
6874
key = value.key
6975
if not isinstance(key, bytes):
7076
raise TypeError("payload key must be a bytes object")
@@ -80,10 +86,17 @@ def decode_legacy(self, value: KafkaPayload) -> Commit:
8086

8187
topic_name, partition_index, group = key.decode("utf-8").split(":", 3)
8288
offset = int(val.decode("utf-8"))
83-
return Commit(
89+
90+
commit = Commit(
8491
group,
8592
Partition(Topic(topic_name), int(partition_index)),
8693
offset,
8794
orig_message_ts.timestamp(),
8895
None,
8996
)
97+
98+
if max_times_to_log_legacy_message > 0:
99+
max_times_to_log_legacy_message -= 1
100+
logger.warn(f"Legacy commit message found: {commit}")
101+
102+
return commit

0 commit comments

Comments
 (0)