cloudberry icon indicating copy to clipboard operation
cloudberry copied to clipboard

Update logfilter.py

Open jangjangji opened this issue 1 month ago • 1 comments

  • Add buffer.seek(0) after truncate to reset file pointer position
  • Add isinstance and len check before accessing item[16] to prevent IndexError
  • Improve robustness when processing malformed CSV log entries

Fixes #ISSUE_Number

What does this PR do?

This PR fixes two issues in the CsvFlatten class in gplogfilter:

  1. Buffer pointer reset: Added buffer.seek(0) after truncate(0) to properly reset the StringIO file pointer position.
  2. Index bounds checking: Added validation before accessing item[16] to prevent IndexError on malformed CSV rows.

Type of Change

  • [x] Bug fix (non-breaking change)
  • [ ] New feature (non-breaking change)
  • [ ] Breaking change (fix or feature with breaking changes)
  • [ ] Documentation update

Test Plan

  • [x] Manual testing with production CSV log files
  • [x] Verified gplogfilter correctly filters CSV logs with time range and pattern matching
  • [ ] Unit tests added/updated
  • [ ] Integration tests added/updated
  • [ ] Passed make installcheck
  • [ ] Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:
No measurable impact expected.

User-facing changes:
None (internal logic improvement only).

Dependencies:
No changes.


Checklist


Additional Context

N/A


CI Skip Instructions


jangjangji avatar Nov 07 '25 01:11 jangjangji

Looks good, ship it.

Thanks for reviewing!

jangjangji avatar Nov 13 '25 07:11 jangjangji