EventIndexPanel: Catch getStats failures.

Getting the stats can fail when used with Seshat. Tantivy periodically
garbage collects its files. Smaller files are merged and the old ones
are removed.

If garbage collection occurs while we try to get the stats, which go
trough the files and figure out their sizes, we can end up trying to
figure out the file size of a removed file. The getStats call will fail
in this case but we can ignore the failure since we will likely get a
nice result next time we try.
This commit is contained in:
Damir Jelić 2020-02-18 12:21:47 +01:00
parent 9e3b0fdf7c
commit 1897d67818
2 changed files with 32 additions and 8 deletions

View file

@ -48,7 +48,16 @@ export default class ManageEventIndexDialog extends React.Component {
updateCurrentRoom = async(room) => {
const eventIndex = EventIndexPeg.get();
const stats = await eventIndex.getStats();
let stats;
// This call may fail if sporadically, not a huge issue as we will try
// later again and probably succeed.
try {
stats = await eventIndex.getStats();
} catch {
return;
}
let currentRoom = null;
if (room) currentRoom = room.name;
@ -85,12 +94,16 @@ export default class ManageEventIndexDialog extends React.Component {
if (eventIndex !== null) {
eventIndex.on("changedCheckpoint", this.updateCurrentRoom);
const stats = await eventIndex.getStats();
try {
const stats = await eventIndex.getStats();
eventIndexSize = stats.size;
eventCount = stats.eventCount;
} catch {
}
const roomStats = eventIndex.crawlingRooms();
eventIndexSize = stats.size;
crawlingRoomsCount = roomStats.crawlingRooms.size;
roomCount = roomStats.totalRooms.size;
eventCount = stats.eventCount;
const room = eventIndex.currentRoom();
if (room) currentRoom = room.name;

View file

@ -39,7 +39,15 @@ export default class EventIndexPanel extends React.Component {
updateCurrentRoom = async (room) => {
const eventIndex = EventIndexPeg.get();
const stats = await eventIndex.getStats();
let stats;
// This call may fail if sporadically, not a huge issue as we will try
// later again and probably succeed.
try {
stats = await eventIndex.getStats();
} catch {
return;
}
this.setState({
eventIndexSize: stats.size,
@ -70,9 +78,12 @@ export default class EventIndexPanel extends React.Component {
if (eventIndex !== null) {
eventIndex.on("changedCheckpoint", this.updateCurrentRoom);
const stats = await eventIndex.getStats();
eventIndexSize = stats.size;
roomCount = stats.roomCount;
try {
const stats = await eventIndex.getStats();
eventIndexSize = stats.size;
roomCount = stats.roomCount;
} catch {
}
}
this.setState({