Skip to content

Commit

Permalink
* Fixed a bug where, in some cases, Striker UI would hang. This was c…
Browse files Browse the repository at this point in the history
…aused by the recent fix to prevent timeouts after long periods of a system being offline causing a timeout during the resync phase.

Signed-off-by: Digimer <[email protected]>
  • Loading branch information
Digimer committed Feb 22, 2018
1 parent 94e15fd commit 7a13de9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
10 changes: 5 additions & 5 deletions AN/Tools/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,7 @@ sub update_time
my $parameter = shift;
my $an = $self->parent;
$an->Alert->_set_error;
$an->Log->entry({log_level => 3, title_key => "tools_log_0001", title_variables => { function => "update_time" }, message_key => "tools_log_0002", file => $THIS_FILE, line => __LINE__});
$an->Log->entry({log_level => 2, title_key => "tools_log_0001", title_variables => { function => "update_time" }, message_key => "tools_log_0002", file => $THIS_FILE, line => __LINE__});

my $id = $parameter->{id};
my $file = $parameter->{file};
Expand Down Expand Up @@ -2409,12 +2409,12 @@ WHERE
AND
updated_by = ".$an->data->{sys}{use_db_fh}->quote($file).";";

$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => {
name1 => "query", value1 => $query
}, file => $THIS_FILE, line => __LINE__ });

my $count = $an->DB->do_db_query({id => $id, query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0]; # (->[row]->[column])
$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => {
name1 => "count", value1 => $count
}, file => $THIS_FILE, line => __LINE__ });
if (not $count)
Expand All @@ -2433,7 +2433,7 @@ INSERT INTO
".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{db_timestamp})."
);
";
$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => {
name1 => "query", value1 => $query
}, file => $THIS_FILE, line => __LINE__ });
$an->DB->do_db_write({id => $id, query => $query, source => $THIS_FILE, line => __LINE__});
Expand All @@ -2451,7 +2451,7 @@ WHERE
AND
updated_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{host_uuid}).";
";
$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => {
name1 => "query", value1 => $query
}, file => $THIS_FILE, line => __LINE__ });
$an->DB->do_db_write({id => $id, query => $query, source => $THIS_FILE, line => __LINE__});
Expand Down
2 changes: 1 addition & 1 deletion AN/Tools/ScanCore.pm
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ FROM
WHERE
ram_used_by = ".$an->data->{sys}{use_db_fh}->quote($program_name)."
AND
ram_used_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{host_uuid})."
ram_used_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{host_uuid})."
;";
$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
name1 => "query", value1 => $query,
Expand Down
35 changes: 19 additions & 16 deletions ScanCore/ScanCore
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,6 @@ check_hostname_for_changes($an);
# agents that have registered alerts (pending or historical).
load_agent_strings($an);

# Record the time. This prevents us getting killed if it takes as a while to run after this machine was off
# for a while.
$an->DB->update_time({file => $THIS_FILE});

# Archive, if needed.
archive_if_needed($an);

Expand Down Expand Up @@ -5687,6 +5683,11 @@ sub update_db
update_db_notifications($an);
update_db_recipients($an);
update_db_nodes_cache($an);

# Record the time. This prevents us getting killed if it takes as a while to run after this
# machine was off for a while. We had to wait for the core tables to be updated, which is why
# this is called here.
$an->DB->update_time({file => $THIS_FILE});

update_db_alerts($an);
update_db_power($an);
Expand Down Expand Up @@ -5715,7 +5716,7 @@ sub update_db
sub update_db_nodes_cache
{
my ($an) = @_;
$an->Log->entry({log_level => 3, title_key => "tools_log_0001", title_variables => { function => "update_db_nodes_cache" }, message_key => "tools_log_0002", file => $THIS_FILE, line => __LINE__});
$an->Log->entry({log_level => 2, title_key => "tools_log_0001", title_variables => { function => "update_db_nodes_cache" }, message_key => "tools_log_0002", file => $THIS_FILE, line => __LINE__});

# Now read in all the 'nodes_cache' table records that came from us.
foreach my $id (sort {$a cmp $b} keys %{$an->data->{dbh}})
Expand All @@ -5739,14 +5740,14 @@ FROM
WHERE
node_cache_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{host_uuid})."
;";
$an->Log->entry({log_level => 3, message_key => "an_variables_0002", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0002", message_variables => {
name1 => "id", value1 => $id,
name2 => "query", value2 => $query
}, file => $THIS_FILE, line => __LINE__});

# Do the query against the source DB and loop through the results.
my $results = $an->DB->do_db_query({id => $id, query => $query, source => $THIS_FILE, line => __LINE__});
$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => {
name1 => "results", value1 => $results
}, file => $THIS_FILE, line => __LINE__});
foreach my $row (@{$results})
Expand All @@ -5757,7 +5758,7 @@ WHERE
my $node_cache_data = $row->[3] ? $row->[3] : "NULL";
my $node_cache_note = $row->[4] ? $row->[4] : "NULL";
my $modified_date = $row->[5];
$an->Log->entry({log_level => 3, message_key => "an_variables_0006", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0006", message_variables => {
name1 => "node_cache_uuid", value1 => $node_cache_uuid,
name2 => "node_cache_node_uuid", value2 => $node_cache_node_uuid,
name3 => "node_cache_name", value3 => $node_cache_name,
Expand Down Expand Up @@ -5790,7 +5791,7 @@ WHERE
# needs to be added to any DBs.
foreach my $modified_date (sort {$b cmp $a} keys %{$an->data->{db_data}{unified}{nodes_cache}{modified_date}})
{
$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => {
name1 => "modified_date", value1 => $modified_date,
}, file => $THIS_FILE, line => __LINE__});
foreach my $node_cache_uuid (sort {$a cmp $b} keys %{$an->data->{db_data}{unified}{nodes_cache}{modified_date}{$modified_date}{node_cache_uuid}})
Expand All @@ -5799,7 +5800,7 @@ WHERE
my $node_cache_name = $an->data->{db_data}{unified}{nodes_cache}{modified_date}{$modified_date}{node_cache_uuid}{$node_cache_uuid}{node_cache_name};
my $node_cache_data = $an->data->{db_data}{unified}{nodes_cache}{modified_date}{$modified_date}{node_cache_uuid}{$node_cache_uuid}{node_cache_data};
my $node_cache_note = $an->data->{db_data}{unified}{nodes_cache}{modified_date}{$modified_date}{node_cache_uuid}{$node_cache_uuid}{node_cache_note};
$an->Log->entry({log_level => 3, message_key => "an_variables_0004", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0004", message_variables => {
name1 => "node_cache_node_uuid", value1 => $node_cache_node_uuid,
name2 => "node_cache_name", value2 => $node_cache_name,
name3 => "node_cache_data", value3 => $node_cache_data,
Expand All @@ -5816,7 +5817,7 @@ WHERE
# \- If we have, see if it exists at the current timestamp.
# \- If not, _INSERT_ it into history schema.
#
$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => {
name1 => "db_data::${id}::nodes_cache::node_cache_uuid::${node_cache_uuid}::seen", value1 => $an->data->{db_data}{$id}{nodes_cache}{node_cache_uuid}{$node_cache_uuid}{seen},
}, file => $THIS_FILE, line => __LINE__});
if (not $an->data->{db_data}{$id}{nodes_cache}{node_cache_uuid}{$node_cache_uuid}{seen})
Expand All @@ -5825,13 +5826,13 @@ WHERE
$an->data->{db_data}{$id}{nodes_cache}{node_cache_uuid}{$node_cache_uuid}{seen} = 1;

# Never seen it. Check if it exists.
$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => {
name1 => "db_data::${id}::nodes_cache::node_cache_uuid::${node_cache_uuid}::exists", value1 => $an->data->{db_data}{$id}{nodes_cache}{node_cache_uuid}{$node_cache_uuid}{'exists'},
}, file => $THIS_FILE, line => __LINE__});
if ($an->data->{db_data}{$id}{nodes_cache}{node_cache_uuid}{$node_cache_uuid}{'exists'})
{
# It exists, but does it exist at this time stamp?
$an->Log->entry({log_level => 3, message_key => "an_variables_0001", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => {
name1 => "db_data::${id}::nodes_cache::modified_date::${modified_date}::node_cache_uuid::${node_cache_uuid}", value1 => $an->data->{db_data}{$id}{nodes_cache}{modified_date}{$modified_date}{node_cache_uuid}{$node_cache_uuid},
}, file => $THIS_FILE, line => __LINE__});
if (not $an->data->{db_data}{$id}{nodes_cache}{modified_date}{$modified_date}{node_cache_uuid}{$node_cache_uuid})
Expand All @@ -5853,7 +5854,7 @@ AND
;";
# Now record the query in the array
$query =~ s/'NULL'/NULL/g;
$an->Log->entry({log_level => 3, message_key => "an_variables_0002", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0002", message_variables => {
name1 => "id", value1 => $id,
name2 => "query", value2 => $query
}, file => $THIS_FILE, line => __LINE__});
Expand Down Expand Up @@ -5885,7 +5886,7 @@ INSERT INTO
);";
# Now record the query in the array
$query =~ s/'NULL'/NULL/g;
$an->Log->entry({log_level => 3, message_key => "an_variables_0002", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0002", message_variables => {
name1 => "id", value1 => $id,
name2 => "query", value2 => $query
}, file => $THIS_FILE, line => __LINE__});
Expand Down Expand Up @@ -5922,7 +5923,7 @@ INSERT INTO
);";
# Now record the query in the array
$query =~ s/'NULL'/NULL/g;
$an->Log->entry({log_level => 3, message_key => "an_variables_0002", message_variables => {
$an->Log->entry({log_level => 2, message_key => "an_variables_0002", message_variables => {
name1 => "id", value1 => $id,
name2 => "query", value2 => $query
}, file => $THIS_FILE, line => __LINE__});
Expand All @@ -5948,6 +5949,8 @@ INSERT INTO
}
}

die $THIS_FILE." ".__LINE__."; testing...\n";

return(0);
}

Expand Down

0 comments on commit 7a13de9

Please sign in to comment.