mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-23 12:47:56 +00:00
Merge merge-pt-agent-2.
This commit is contained in:
19
bin/pt-agent
19
bin/pt-agent
@@ -7366,15 +7366,7 @@ sub run_service {
|
||||
# if 1) the service spools data and 2) there is data.
|
||||
my $file_size = (-s $tmp_data_file) || 0;
|
||||
$logger->debug("$tmp_data_file size: " . ($file_size || 0) . " bytes");
|
||||
if ( $file_size > $max_data ) {
|
||||
$logger->error("Data file is larger than $max_data, the service "
|
||||
. "may be malfunctioning, stopping service");
|
||||
stop_service(
|
||||
service => $service->name,
|
||||
lib_dir => $lib_dir,
|
||||
);
|
||||
}
|
||||
elsif ( $use_spool && $file_size ) {
|
||||
if ( $use_spool && $file_size ) {
|
||||
# Save metadata about this sample _first_, because --send-data looks
|
||||
# for the data file first, then for a corresponding .meta file. If
|
||||
# we write the data file first, then we create a race condition: while
|
||||
@@ -7391,11 +7383,13 @@ sub run_service {
|
||||
);
|
||||
$metadata->{run_time} = sprintf('%.6f', time - $start_time);
|
||||
(my $meta_file = $data_file) =~ s/\.data/\.meta/;
|
||||
my $json_metadata = as_json($metadata, json => $json);
|
||||
write_to_file(
|
||||
data => as_json($metadata, json => $json),
|
||||
data => $json_metadata,
|
||||
file => "$data_dir/$meta_file",
|
||||
);
|
||||
|
||||
if ( $file_size <= $max_data ) {
|
||||
# Use system mv instead of Perl File::Copy::move() because it's
|
||||
# unknown if the Perl version will do an optimized move, i.e.
|
||||
# simply move the inode, _not_ copy the file. A system mv on
|
||||
@@ -7410,6 +7404,11 @@ sub run_service {
|
||||
}
|
||||
$exit_status |= $cmd_exit_status;
|
||||
}
|
||||
else {
|
||||
$logger->error("Data file is larger than $max_data, skipping: "
|
||||
. ($json_metadata || ''));
|
||||
}
|
||||
}
|
||||
|
||||
# Remove staged files. Anything to save should have been moved
|
||||
# from staging by a task.
|
||||
|
Reference in New Issue
Block a user