mirror of https://github.com/apache/cassandra
merge from 2.0
This commit is contained in:
commit
1394b128c6
|
|
@ -50,6 +50,7 @@
|
|||
* Make repair -pr work with -local (CASSANDRA-7450)
|
||||
* Fix error in sstableloader with -cph > 1 (CASSANDRA-8007)
|
||||
Merged from 2.0:
|
||||
* Archive any commitlog segments present at startup (CASSANDRA-6904)
|
||||
* CrcCheckChance should adjust based on live CFMetadata not
|
||||
sstable metadata (CASSANDRA-7978)
|
||||
* token() should only accept columns in the partitioning
|
||||
|
|
|
|||
|
|
@ -90,9 +90,7 @@ public class CommitLog implements CommitLogMBean
|
|||
*/
|
||||
public int recover() throws IOException
|
||||
{
|
||||
archiver.maybeRestoreArchive();
|
||||
|
||||
File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(new FilenameFilter()
|
||||
FilenameFilter unmanagedFilesFilter = new FilenameFilter()
|
||||
{
|
||||
public boolean accept(File dir, String name)
|
||||
{
|
||||
|
|
@ -101,8 +99,19 @@ public class CommitLog implements CommitLogMBean
|
|||
// ahead and allow writes before recover(), and just skip active segments when we do.
|
||||
return CommitLogDescriptor.isValid(name) && !instance.allocator.manages(name);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// submit all existing files in the commit log dir for archiving prior to recovery - CASSANDRA-6904
|
||||
for (File file : new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter))
|
||||
{
|
||||
archiver.maybeArchive(file.getPath(), file.getName());
|
||||
archiver.maybeWaitForArchiving(file.getName());
|
||||
}
|
||||
|
||||
assert archiver.archivePending.isEmpty() : "Not all commit log archive tasks were completed before restore";
|
||||
archiver.maybeRestoreArchive();
|
||||
|
||||
File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter);
|
||||
int replayed = 0;
|
||||
if (files.length == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -120,6 +120,28 @@ public class CommitLogArchiver
|
|||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Differs from the above because it can be used on any file, rather than only
|
||||
* managed commit log segments (and thus cannot call waitForFinalSync).
|
||||
*
|
||||
* Used to archive files present in the commit log directory at startup (CASSANDRA-6904)
|
||||
*/
|
||||
public void maybeArchive(final String path, final String name)
|
||||
{
|
||||
if (Strings.isNullOrEmpty(archiveCommand))
|
||||
return;
|
||||
|
||||
archivePending.put(name, executor.submit(new WrappedRunnable()
|
||||
{
|
||||
protected void runMayThrow() throws IOException
|
||||
{
|
||||
String command = archiveCommand.replace("%name", name);
|
||||
command = command.replace("%path", path);
|
||||
exec(command);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public boolean maybeWaitForArchiving(String name)
|
||||
{
|
||||
Future<?> f = archivePending.remove(name);
|
||||
|
|
@ -179,7 +201,11 @@ public class CommitLogArchiver
|
|||
|
||||
File toFile = new File(DatabaseDescriptor.getCommitLogLocation(), descriptor.fileName());
|
||||
if (toFile.exists())
|
||||
throw new IllegalStateException("Trying to restore archive " + fromFile.getPath() + ", but the same segment already exists in the restore location: " + toFile.getPath());
|
||||
{
|
||||
logger.debug("Skipping restore of archive {} as the segment already exists in the restore location {}",
|
||||
fromFile.getPath(), toFile.getPath());
|
||||
continue;
|
||||
}
|
||||
|
||||
String command = restoreCommand.replace("%from", fromFile.getPath());
|
||||
command = command.replace("%to", toFile.getPath());
|
||||
|
|
|
|||
Loading…
Reference in New Issue