Skip to content

Commit

Permalink
[XrdCl] Implement xrdcp --retry.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Jun 7, 2021
1 parent e7d0057 commit 290367f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/man/xrdcp.1
Expand Up @@ -91,6 +91,11 @@ use \fIproxyaddr\fB:\fIproxyport\fR as a SOCKS4 proxy. Only numerical addresses
.RS 5
recursively copy all files starting at the given source directory.

.RE
\fB--retry\fR
.RS 5
retry failed copy-jobs.

.RE
\fB--server\fR
.RS 5
Expand Down
2 changes: 1 addition & 1 deletion src/XrdApps/XrdCpConfig.cc
Expand Up @@ -955,7 +955,7 @@ void XrdCpConfig::Usage(int rc)
"-r | --recursive recursively copies all source files\n"
" --rm-bad-cksum remove the target file if checksum verification failed\n"
" (enables also POSC semantics)\n"
"-t | --retry <n> maximum number of times to retry rejected connections\n"
"-t | --retry <n> maximum number of times to retry failed copy-jobs\n"
" --server runs in a server environment with added operations\n"
"-s | --silent produces no output other than error messages\n"
"-y | --sources <n> uses up to the number of sources specified in parallel\n"
Expand Down
3 changes: 3 additions & 0 deletions src/XrdCl/XrdClCopy.cc
Expand Up @@ -601,6 +601,9 @@ int main( int argc, char **argv )
if( config.nStrm != 0 )
env->PutInt( "SubStreamsPerChannel", config.nStrm + 1 /*stands for the control stream*/ );

if( config.Retry != -1 )
env->PutInt( "retry", config.Retry );

if( config.Want( XrdCpConfig::DoNoTlsOK ) )
env->PutInt( "NoTlsOK", 1 );

Expand Down
24 changes: 21 additions & 3 deletions src/XrdCl/XrdClCopyProcess.cc
Expand Up @@ -54,9 +54,11 @@ namespace
XrdSysSemaphore *sem = 0 ):
pJob(job), pProgress(progress), pCurrentJob(currentJob),
pTotalJobs(totalJobs), pSem(sem),
pRetryCnt( XrdCl::DefaultRetryWrtAtLBLimit )
pWrtRetryCnt( XrdCl::DefaultRetryWrtAtLBLimit ),
pRetryCnt( 0 )
{
XrdCl::DefaultEnv::GetEnv()->GetInt( "RetryWrtAtLBLimit", pRetryCnt );
XrdCl::DefaultEnv::GetEnv()->GetInt( "RetryWrtAtLBLimit", pWrtRetryCnt );
XrdCl::DefaultEnv::GetEnv()->GetInt( "retry", pRetryCnt );
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -92,7 +94,10 @@ namespace
while( true )
{
st = pJob->Run( pProgress );
if( !st.IsOK() && st.code == XrdCl::errRetry && pRetryCnt > 0 )
//--------------------------------------------------------------------
// Retry due to write-recovery
//--------------------------------------------------------------------
if( !st.IsOK() && st.code == XrdCl::errRetry && pWrtRetryCnt > 0 )
{
std::string url;
pJob->GetResults()->Get( "LastURL", url );
Expand Down Expand Up @@ -124,6 +129,18 @@ namespace
pJob->Init();

// we have a new job, let's try again
--pWrtRetryCnt;
continue;
}
//--------------------------------------------------------------------
// Copy job retry
//--------------------------------------------------------------------
if( !st.IsOK() && pRetryCnt > 0 &&
( XrdCl::Status::IsSocketError( st.code ) ||
st.code == XrdCl::errOperationExpired ||
st.code == XrdCl::errThresholdExceeded ) )
{
pJob->GetProperties()->Set( "force", true );
--pRetryCnt;
continue;
}
Expand Down Expand Up @@ -164,6 +181,7 @@ namespace
uint16_t pCurrentJob;
uint16_t pTotalJobs;
XrdSysSemaphore *pSem;
int pWrtRetryCnt;
int pRetryCnt;
};
};
Expand Down
5 changes: 5 additions & 0 deletions src/XrdCl/XrdClStatus.hh
Expand Up @@ -131,6 +131,11 @@ namespace XrdCl
return (code/100)+50;
}

inline static bool IsSocketError( uint16_t code )
{
return int( code / 100 ) == 1;
}

//--------------------------------------------------------------------------
//! Create a string representation
//--------------------------------------------------------------------------
Expand Down

0 comments on commit 290367f

Please sign in to comment.