Commit a39d84f3 authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Don't overwrite the snapshot if the current database comes from it.

The snapshot is taken whilst the dumping job is still running. It means that
on a restored database, beekeeper will first garbage-collect the job, and
then re-run it.

Previously, the job would re-dump everything and overwrite the snapshot.
This is not the case any more.
parent 5e30e07a
......@@ -34,6 +34,8 @@ The following parameters are accepted:
- output_db [string] : URL of a database to write the dump to. In this
mode, the Runnable acts like MySQLTransfer
- skip_dump : boolean. 1 to skip the dump process
If "table_list" is undefined or maps to an empty list, the list
of tables to be dumped is decided accordingly to "exclude_list" (EL)
and "exclude_ehive" (EH). "exclude_list" controls the whole list of
......@@ -192,13 +194,26 @@ sub run {
);
print "$cmd\n" if $self->debug;
# We have to skip the dump
return if ($self->param('skip_dump'));
# Check whether the current database has been restored from a snapshot.
# If it is the case, we shouldn't re-dump and overwrite the file.
# We also check here the value of the "skip_dump" parameter
my $completion_signature = sprintf('dump_%d_restored', $self->input_job->dbID);
return if $self->param('skip_dump') or $self->param($completion_signature);
# OK, we can dump
if(my $return_value = system($cmd)) {
die "system( $cmd ) failed: $return_value";
}
# We add the signature to the dump, so that the job won't rerun on a
# restored database
my $extra_sql = qq{echo "INSERT INTO pipeline_wide_parameters VALUES ('$completion_signature', 1);\n" $output};
# We're very lucky that gzipped streams can be concatenated and the
# output is still valid !
$extra_sql =~ s/>/>>/;
if(my $return_value = system($extra_sql)) {
die "system( $extra_sql ) failed: $return_value";
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment