-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
AttributeError: 'PartitionRecords' object has no attribute 'message_idx' #1290
Comments
Are you seeing any errors in the logs related to unpacking message sets? |
No, this is issued on a simple I inspected the code, and the
The error might occur because I suspect a race condition or similar because the error occurs nearly "randomly" and was discovered on a service starting 40 consumers (individual processes, not threads) at once. Different processes crash due to this error when the entire pool is restarted, so it's not related to a specific topic (the 40 processes all consume different topics). I think the error can be avoided by simply initializing the variable in the class, but I am unsure of what the default value could be otherwise I would gladly set up a PR. |
Yes, you are correct. My question is whether you see any other error log messages related to message unpacking? The root cause is a non-empty messageset yielding an empty list of actual messages. This is strange and unexpected behavior and suggests either that there is a lower level protocol issue, that message compression is failing, or that the message unpacking itself has a bug. The fix for the attribute error is obvious, but I'm much more interested in determining if there is a root cause. |
I don't have access to the logs right now, but I do not think I have more to report : anything in the stack trace above what I copy pasted (and which is not shown in the current bug report) are my function calls only. To be sure I will review the logs tomorrow, and will update this ticket accordingly. |
Just a statuts update, I was not available to gather the logs today, so I will do it on Monday. |
Logs before crash:
There is no specific issue related to message unpacking, in fact everything seems as fine as usual. After those logs, my code calls And it crashes. |
I have the same problem. Very simple consumer, worked fine with 1.3.4, but poll() fails every time with 1.3.5 and current master. Brokers are running Kafka 0.11. Here's my client code, with host names changed. poll() hangs a number of seconds then fails (or times out, and then fails on the next try if I have a shorter timeout). #!/usr/bin/python -u
from kafka import KafkaConsumer
topic = 'test_topic'
group_id = 'crash_test'
bootstrap_servers = 'node1.my_kafka.com:9093,node2.my_kafka.com:9093,node3.my_kafka.com:9093'
consumer = KafkaConsumer(
topic,
bootstrap_servers=bootstrap_servers,
group_id=group_id,
security_protocol='SSL',
ssl_cafile='/etc/ssl/kafka-ca.crt',
ssl_certfile='/etc/ssl/kafka-client.crt',
ssl_keyfile='/etc/ssl/kafka-client.key',
ssl_check_hostname=True,
auto_offset_reset='earliest'
)
try:
print('consuming')
while True:
print('calling poll')
results = consumer.poll(timeout_ms=30000)
print('returned from poll')
if results:
for records in results.values():
for msg in records:
print(msg.key, msg.value)
else:
print("no results")
except KeyboardInterrupt:
pass
consumer.close() The output is:
|
Are your topics compressed? compacted? Both? Neither? |
Compacted, but not compressed. |
Same here, compacted but not compressed. |
I put a little debugging in the PartitionRecords() constructor: class PartitionRecords(object):
def __init__(self, fetch_offset, tp, messages):
self.fetch_offset = fetch_offset
self.topic_partition = tp
self.messages = messages
print("fetch_offset: {}".format(fetch_offset))
# When fetching an offset that is in the middle of a
# compressed batch, we will get all messages in the batch.
# But we want to start 'take' at the fetch_offset
for i, msg in enumerate(messages):
print("message offset: {}".format(msg.offset))
if msg.offset == fetch_offset:
self.message_idx = i and got the following result:
So self.message_idx never gets set. It feels like self.message_idx should be set to the first message offset, if it is greater than the fetch offset. But I don't really know the code, so I could be wrong. |
Oops, that would be wrong. Perhaps it should be initialized to 0, so it points to the first message if there is no offset match. |
This issue was caused by ffc7cae and I think we should probably just revert that for now and head back to the drawing board on that issue. |
I've reverted the PR that caused this error and reopened that issue (related to seeking in a compressed topic). I am closing this issue. Please feel free to re-open if the AttributeError persists. |
I know it's closed, but for the record while the topic is not compressed per se, the messages we send are compressed with |
kafka-python is 1.3.5
My code is basically trying to do:
pollResults = self._consumer.poll(timeout, maxResults)
and I run into the following exception from within the library:
The text was updated successfully, but these errors were encountered: