Code

Added Debug code for concurrent DB access problems.
authorjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 1 Apr 2008 06:15:44 +0000 (06:15 +0000)
committerjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 1 Apr 2008 06:15:44 +0000 (06:15 +0000)
Lock files already get removed when creating DB.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10097 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/modules/DBsqlite.pm

index 893ccfb3656f2e10c4df5f1adea880c4bf6a6cad..e18617b874502a3dda7fa90c27410788da7bab24 100755 (executable)
@@ -2125,39 +2125,32 @@ if ($no_bus > 0) {
 }
 
 # connect to gosa-si job queue
-unlink($job_queue_file_name.".si.lock");
 $job_db = GOSA::DBsqlite->new($job_queue_file_name);
 $job_db->create_table($job_queue_tn, \@job_queue_col_names);
 
 # connect to known_clients_db
-unlink($known_clients_file_name.".si.lock");
 $known_clients_db = GOSA::DBsqlite->new($known_clients_file_name);
 $known_clients_db->create_table($known_clients_tn, \@known_clients_col_names);
 
 # connect to known_server_db
-unlink($known_server_file_name.".si.lock");
 $known_server_db = GOSA::DBsqlite->new($known_server_file_name);
 $known_server_db->create_table($known_server_tn, \@known_server_col_names);
 
 # connect to login_usr_db
-unlink($login_users_file_name.".si.lock");
 $login_users_db = GOSA::DBsqlite->new($login_users_file_name);
 $login_users_db->create_table($login_users_tn, \@login_users_col_names);
 
 # connect to fai_server_db and fai_release_db
-unlink($fai_server_file_name.".si.lock");
 $fai_server_db = GOSA::DBsqlite->new($fai_server_file_name);
 $fai_server_db->create_table($fai_server_tn, \@fai_server_col_names);
 $fai_server_db->create_table($fai_release_tn, \@fai_release_col_names);
 
 # connect to packages_list_db
-unlink($packages_list_file_name.".si.lock");
 unlink($packages_list_file_name);
 $packages_list_db = GOSA::DBsqlite->new($packages_list_file_name);
 $packages_list_db->create_table($packages_list_tn, \@packages_list_col_names);
 
 # connect to messaging_db
-unlink($messaging_file_name.".si.lock");
 $messaging_db = GOSA::DBsqlite->new($messaging_file_name);
 $messaging_db->create_table($messaging_tn, \@messaging_col_names);
 
index 06f2d0e0efbeb49f8e2125b1cdc7b6b4ee574215..8d5ff4705c0764b5b89c4a4e599f11724d20b3bd 100644 (file)
@@ -19,6 +19,7 @@ sub new {
     my $lock = $db_name.".si.lock";
        # delete existing lock - instance should be running only once
        if(stat($lock)) {
+               &main::daemon_log("DEBUG: Removed existing lock $lock.", 7);
                unlink($lock);
        }
     my $self = {dbh=>undef,db_name=>undef,db_lock=>undef,db_lock_handle=>undef};
@@ -36,9 +37,13 @@ sub lock_exists : locked {
     my $funcname=shift;
     my $lock = $self->{db_lock};
     my $result=(-f $lock);
+       my $i=0;
     if($result) {
-        #&main::daemon_log("(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock found", 8);
+               if($i>10) {
+               &main::daemon_log("WARNING: (".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock found. Waiting time: ".($i*500)." us", 8);
+               }
         usleep 500;
+               $i++;
     }
     return $result;
 }