Recreate search index if its format is outdated
#802
Merged
kiwii
merged 6 commits from KitaitiMakoto/Plume:invalid-index
into main
4 years ago
Reviewers
Request review
No reviewers
Labels
Clear labels
Related to the REST API
Code running on the server
Stuff related to Federation
Related to the front-end
Translations, and related code
More about project management or code than the project itself
The building, or installation process of Plume
Something isn't working
We need to talk
New feature or request
This is a new feature
Compatibility with different browsers, readers and OS
Related to an external package that Plume uses
UI/UX related issues and PRs
Good for newcomers
Extra attention is needed
Issues affecting only mobile UX
How elements're rendered out for the end user
Something else needs to be fixed first
This issue or pull request already exists
This PR is not complete yet
Issues concern a limited number of instances
This doesn't seem right
Need to be discussed by the community (on Loomio)
This PR is ready to be reviewed
Proposed ideas worth considering
This is issue has been created after a vote on Loomio
This will not be worked on
Apply labels
A: API
Related to the REST API
A: Backend
Code running on the server
A: Federation
Stuff related to Federation
A: Front-End
Related to the front-end
A: I18N
Translations, and related code
A: Meta
More about project management or code than the project itself
A: Security
Build
The building, or installation process of Plume
C: Bug
Something isn't working
C: Discussion
We need to talk
C: Enhancement
New feature or request
C: Feature
This is a new feature
Compatibility
Compatibility with different browsers, readers and OS
Dependency
Related to an external package that Plume uses
Design
UI/UX related issues and PRs
Documentation
Good first issue
Good for newcomers
Help welcome
Extra attention is needed
Mobile
Issues affecting only mobile UX
Rendering
How elements're rendered out for the end user
S: Blocked
Something else needs to be fixed first
S: Duplicate
This issue or pull request already exists
S: Incomplete
This PR is not complete yet
S: Instance specific
Issues concern a limited number of instances
S: Invalid
This doesn't seem right
S: Needs Voting/Discussion
Need to be discussed by the community (on Loomio)
S: Ready for review
This PR is ready to be reviewed
Suggestion
Proposed ideas worth considering
S: Voted on Loomio
This is issue has been created after a vote on Loomio
S: Wontfix
This will not be worked on
No Label
A: API
A: Backend
A: Federation
A: Front-End
A: I18N
A: Meta
A: Security
Build
C: Bug
C: Discussion
C: Enhancement
C: Feature
Compatibility
Dependency
Design
Documentation
Good first issue
Help welcome
Mobile
Rendering
S: Blocked
S: Duplicate
S: Incomplete
S: Instance specific
S: Invalid
S: Needs Voting/Discussion
S: Ready for review
Suggestion
S: Voted on Loomio
S: Wontfix
Milestone
Set milestone
Clear milestone
No items
No Milestone
Assignees
Assign users
Clear assignees
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
No dependencies set.
Reference: Plume/Plume#802
Reference in New Issue
There is no content yet.
Delete Branch 'KitaitiMakoto/Plume:invalid-index'
Deleting a branch is permanent. It CANNOT be undone. Continue?
No
Yes
Hi,
I fixed the problem #788.
This patch detects outdated search index and recreates it.
some questions 🙋🏻♀️
@ -101,0 +102,4 @@
UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers);
if let Err(Error::Search(SearcherError::InvalidIndexDataError)) = open_searcher {
UnmanagedSearcher::create(&CONFIG.search_index, &CONFIG.search_tokenizers)
.expect("main: recreating search index error. Try backing up search index, removing it and running `plm search init`");
how unsafe (or unsavoury?) would it be to do the thing we suggest here, instead of suggesting it?
rename the index file to append the date-time, and create a new (empty?) index?
is the functionality for (re)creating an index exclusively in
plm
?Renaming current search index as a backup and creating new index is good. There's a point to discuss: how and who remove that backup?
Administrator might want to restore the index several days later for some purpose. If Plume removes backup directory after it started running successfully, they cannot achieve their purpose. So, remaining backup directory and recomment admin to remove it at any point in time.
On the other hand, most of admins will forget remove backup directories even if Plume show a message recommending removing later. If they remove it themselves, they remember the existence of backup directory and can add removing it to their to-do list. This is why Plume shows message and exists in my patch.
Which is better do you think?
why would we need to keep our restore an index which Plume cannot load?
what could the admin do, that we can't? (why aren't we doing that?)
Admin can run Plume v0.4.0 with older index.
But your point is reasonable. It's the rare case what I imagine. I will rewrite my patch to temporatrilly backup older index and remove it after successfully recreating new index. Thank you for the advice.
I've rewritten. Can you check it out, please?
some comments
@ -101,0 +119,4 @@
backup_path.display()
);
}
Ok(searcher)
who is this return for?
I've removed it!
@ -101,0 +123,4 @@
},
)
})
.expect("main: error on recreating search index in new index format");
any advice on what to do here if this happens?
I added message to take action.
@ -101,1 +126,4 @@
.expect("main: error on recreating search index in new index format");
open_searcher = UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers);
}
#[allow(clippy::match_wild_err_arm)]
is this clippy still necessary?
I think so. There are many types of error in Plume and they doesn't matter here. But I'm not good at Rust. Is there better way to the errors?
@ -101,2 +128,3 @@
}
#[allow(clippy::match_wild_err_arm)]
let searcher = match UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers) {
let searcher = match open_searcher {
maybe we should put the above
if let
into thismatch
as well…No, what
if let
block does is creating search index. It need to be done before opening search index.@ -101,0 +109,4 @@
let backup_path = format!("{}.{}", ¤t_path.display(), Utc::now().timestamp());
let backup_path = Path::new(&backup_path);
fs::rename(current_path, backup_path)
.expect("main: error on backing up search index directory for recreating");
is this a user-facing error message? should it go thru translation?
This is a message for administrators. I think it's not needed to translate as such other error messages in this file.
administrators are users too.
anyway, let's ear-mark this for a next round
I filed an issue: #803
@ -101,0 +114,4 @@
if fs::remove_dir_all(backup_path).is_err() {
eprintln!(
"error on removing backup directory: {}. it remains",
backup_path.display()
this is a user-facing error message, so it should go thru translation
The same to the above comment.
@ -101,0 +118,4 @@
);
}
} else {
panic!("main: error on recreating search index in new index format. remove search index and run `plm search init` manually");
this is a user-facing error message, so it should go thru translation
Ditto.
👍
6de9a1f1c8
into main 4 years agoThanks for the merge.
Reviewers
6de9a1f1c8
.