Project

General

Profile

Bug #527

Greyhole stops when two instances try to write to the DB at the same time

Added by gboudreau over 11 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
Greyhole
Target version:
-
Start date:
05/18/2010
Due date:
% Done:

0%


Description

When two instances of greyhole try to update the sqlite database at the same time, one of the instances could print a fatal error and die.
This is because sqlite returns an error when this happens, and the current greyhole code doesn't handle such errors.
Not that this is not a problem with MySQL.

This is where it failed yesterday:
$query = sprintf("INSERT INTO tasks (action, share, full_path, complete) VALUES ('write', '%s', '%s', 'yes')",
db_escape_string($share),
db_escape_string(empty($file_path) ? $filename : clean_dir("$file_path/$filename"))
);
db_query($query) or gh_log(CRITICAL, "Can't insert write task: " . db_error());

but it can also fail everywhere I try to INSERT/UPDATE/DELETE to the DB using db_query() or gh_log(CRITICAL, ...
(CRITICAL = log error then die)

CTRL-F "gh_log(CRITICAL"; if it dies when a INSERT/UPDATE/DELETE fails, this needs to be handled.
But anyway, the retry code sould be in db_query, for the sqlite branch, so changing it there will apply to all of those.

Not sure if you want to retry on any error message, or just "database is locked"..?

Low priority because if the greyhole daemon dies this way, monit will restart it within a minute.

History

#1 Updated by bigfoot65 over 7 years ago

  • Status changed from New to Closed
  • Assignee deleted (cpg)

No longer valid.

Also available in: Atom