Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unsafe method panic, reduce log, slice work with id #77

Merged
merged 7 commits into from
Feb 13, 2025

Conversation

luohoufu
Copy link
Contributor

@luohoufu luohoufu commented Feb 8, 2025

What does this PR do

This pull request includes several updates and improvements across multiple files. The changes primarily involve enhancing logging messages for better clarity, adding error handling, and updating function implementations. Below are the most important changes grouped by theme:

Logging Improvements:

  • Updated various logging messages in modules/queue/disk_queue/consumer.go to include more detailed information, such as workerID. This improves traceability and debugging. [1] [2] [3] [4] [5] [6]
  • Enhanced logging in plugins/elastic/bulk_indexing/bulk_indexing.go to provide more context by including the workerID in log messages. This helps in identifying the specific worker handling the task. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Error Handling:

  • Added error logging for invalid message sizes in modules/queue/disk_queue/consumer.go to provide more detailed error messages when encountering issues with message sizes. [1] [2]

Function Implementations:

  • Introduced a new function UnsafeGetStringToBytes in core/util/bytes.go to handle empty string cases and avoid nil slices. This function provides a safer alternative for converting strings to bytes.
  • Replaced the usage of UnsafeStringToBytes with UnsafeGetStringToBytes in modules/queue/disk_queue/module.go to ensure the safer handling of string-to-byte conversions.

Typographical Fixes:

  • Corrected a typo in the function name from getElasticsearchMeatadata to getElasticsearchMetadata in plugins/elastic/bulk_indexing/bulk_indexing.go. [1] [2]

These changes collectively improve the robustness, clarity, and maintainability of the codebase.

Rationale for this change

Standards checklist

  • The PR title is descriptive
  • The commit messages are semantic
  • Necessary tests are added
  • Updated the release notes
  • Necessary documents have been added if this is a new feature
  • Performance tests checked, no obvious performance degradation

@luohoufu luohoufu requested review from medcl and silenceqi February 8, 2025 08:29
//log.Debugf("save offset: %v", offset.EncodeToString())

err = kv.AddValue(ConsumerOffsetBucket, util.UnsafeStringToBytes(getCommitKey(k, consumer)), []byte(offset.EncodeToString()))
err = kv.AddValue(ConsumerOffsetBucket, util.UnsafeGetStringToBytes(getCommitKey(k, consumer)), []byte(offset.EncodeToString()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not fix UnsafeStringToBytes rather create another function with same behavior, i don't think it is necessary, and the output of getCommitKey should not be empty, if empty you should call panic, i don't really get the case that you can fix with the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when getCommitKey not empty, the return []byte just has len , but cap=0, so this k.AddValue will panic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@luohoufu luohoufu requested a review from medcl February 12, 2025 03:37
@medcl medcl merged commit 969518a into main Feb 13, 2025
5 checks passed
@medcl medcl deleted the fix_consumer_patch-1 branch February 13, 2025 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants