3 ms·
I wrote some code that was pulling batches of events off a queue, doing some processing and then writing them out to HDFS. The inner loop was something like:
by zaptheimpaler 9y ago
I wrote some code that was pulling batches of events off a queue, doing some processing and then writing them out to HDFS.
The inner loop was something like:
while message:
converted_event = new Event()
for event in message.events():
converted_event.set_fields(event)
write_to_hdfs(converted_event)
Can you spot the bug? Led to a month of corrupted data before I noticed..
The `set_fields` method does not clear all fields, so every event had more and more junk data than the one before it. All because i thought i would be clever and get some performance gains by initializing `converted_event` outside the inner loop.