cloudberry
cloudberry copied to clipboard
Update logfilter.py
- 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:
- Buffer pointer reset: Added
buffer.seek(0)aftertruncate(0)to properly reset the StringIO file pointer position. - Index bounds checking: Added validation before accessing
item[16]to preventIndexErroron 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
gplogfiltercorrectly 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
- [x] Followed contribution guide
- [ ] Added/updated documentation
- [x] Reviewed code for security implications
- [ ] Requested review from cloudberry committers
Additional Context
N/A
CI Skip Instructions
Looks good, ship it.
Thanks for reviewing!