# Question about eg2: Fetch single message from disk

**URL:** <https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154>\
**Category:** Challenges\
**Tags:** challenge:kafka\
**Created:** [November 26, 2024, 9:49pm UTC](https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154 "2024-11-26T21:49:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gokul-j99](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gokul-j99/32/3087_2.png) [@gokul-j99](https://forum.codecrafters.io/u/gokul-j99)\
**Post date:** [November 26, 2024, 9:49pm UTC](https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154/1 "2024-11-26T21:49:14Z")

</div>

I’m getting CRC mismatch error. I’m implementing it in Java. The messages are correct but just missing in CRC calculation. Can some one guide?

 ![Screenshot 2024-11-26 at 4.50.15 PM](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/5/51906f6ef226e536a471798b5cfb1b95eda763e6.jpeg)

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [November 26, 2024, 10:03pm UTC](https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154/2 "2024-11-26T22:03:45Z")

</div>

Hi @gokul-j99, Could you [upload your code to GitHub](https://docs.codecrafters.io/features/publish-to-github) and share the link? It will be much easier to debug if I can run it directly.

---

<div class="post-metadata">

**Author:** ![gokul-j99](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gokul-j99/32/3087_2.png) [@gokul-j99](https://forum.codecrafters.io/u/gokul-j99)\
**Post date:** [November 26, 2024, 11:34pm UTC](https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154/3 "2024-11-26T23:34:46Z")

</div>

HI @andy1li Thanks for reply. My code:  
[https://github.com/gokul-j99/code-crafter-kafka/tree/master](https://github.com/gokul-j99/code-crafter-kafka/tree/master)

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [November 27, 2024, 12:36am UTC](https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154/4 "2024-11-27T00:36:37Z")

</div>

Thanks for sharing the link! I’ll take a look and get back to you by the end of the week.

---

<div class="post-metadata">

**Author:** ![gokul-j99](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gokul-j99/32/3087_2.png) [@gokul-j99](https://forum.codecrafters.io/u/gokul-j99)\
**Post date:** [November 29, 2024, 1:20am UTC](https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154/5 "2024-11-29T01:20:14Z")

</div>

Hi, @andy1li Could you identify the issue?

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [December 2, 2024, 6:51am UTC](https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154/7 "2024-12-02T06:51:22Z")

</div>

**EDIT:** The correct approach is to read the entire RecordBatch from disk and return it as-is, without parsing and re-serializing it. In other words, there’s **no need to implement CRC** for this stage.

* * *

Sorry for the delayed response!

It seems that your code hasn’t implemented CRC yet. The CRC value should be calculated over all the bytes that **follow** the CRC field in the record batch. This ensures the integrity of the entire payload after the CRC field.

For reference, you can review the Go implementation in our tester:

> <https://github.com/codecrafters-io/kafka-tester/blob/586d4ddb28f593bc696f384c8bcece681d6b949c/protocol/api/record_batch.go#L58-L61>

---

<div class="post-metadata">

**Author:** ![gokul-j99](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gokul-j99/32/3087_2.png) [@gokul-j99](https://forum.codecrafters.io/u/gokul-j99)\
**Post date:** [December 4, 2024, 5:25am UTC](https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154/9 "2024-12-04T05:25:21Z")

</div>

Thanks, issue resolved

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [December 9, 2024, 5:25am UTC](https://forum.codecrafters.io/t/question-about-eg2-fetch-single-message-from-disk/3154/10 "2024-12-09T05:25:28Z")

</div>

Closed on December 9, 2024, 5:25am UTC

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
