-
Notifications
You must be signed in to change notification settings - Fork 514
tsdb: Format bad sectors only #384
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
base: master
Are you sure you want to change the base?
Conversation
e807513 to
f9a3820
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new FDB_TSDB_CTRL_SET_FORMAT_BAD_SEC_ONLY control command to the time-series database (TSDB) that enables selective formatting of only bad sectors instead of formatting the entire database. This feature aims to prevent data loss by preserving good sectors when corruption is detected during database initialization.
Key changes:
- Added
FDB_TSDB_CTRL_SET_FORMAT_BAD_SEC_ONLYconstant andformat_bad_sec_onlyfield to enable selective bad sector formatting - Implemented new
format_cbcallback function to format individual sectors - Added logic in
fdb_tsdb_initto iteratively check and format only bad sectors when the feature is enabled
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| inc/fdb_def.h | Added new control command constant FDB_TSDB_CTRL_SET_FORMAT_BAD_SEC_ONLY (0x0C) and format_bad_sec_only boolean field to fdb_db struct; reformatted alignment of control command definitions |
| src/fdb_tsdb.c | Implemented format_cb callback for selective sector formatting; added control case handler for the new command; added iterative bad sector detection and formatting logic in fdb_tsdb_init |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8782457 to
43febe1
Compare
|
@armink thanks for the review! I've changed the logic a bit (essentially just copied the bad sector formatting logic over from |
|
My main concern is: in extreme cases, if only one sector is damaged and formatted, will this prevent the entire database from querying and inserting data? |
I don't believe so. My understanding that the sector will be erased and header will be written and marked as AFAICS, it's exactly same logic in Line 1599 in 8856961
|
+Added FDB_TSDB_CTRL_SET_FORMAT_BAD_SEC_ONLY setting to TSDB to format only bad sectors to prevent data loss
Just a follow up on #383 issue. I'd imagine logic like this roughly. What it does is that rather than formatting all sectors it targets only affected sectors and carries on.