Skip to content

Commit

Permalink
[XrdCl] Allow to disable open retry logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed May 28, 2018
1 parent dec6792 commit 6ef8e30
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/man/xrdcp.1
Expand Up @@ -263,6 +263,11 @@ XRD_WRITERECOVERY
Determines if write recovery should be enabled or disabled (enabled by default).
.RE

XRD_OPENRECOVERY
.RS 5
Determines if open recovery should be enabled or disabled for mutable (truncate or create) opens (enabled by default).
.RE

XRD_CONNECTIONWINDOW (-DIConnectionWindow)
.RS 5
A time window for the connection establishment. A connection failure is declared if
Expand Down
1 change: 1 addition & 0 deletions src/XrdCl/XrdClConstants.hh
Expand Up @@ -79,6 +79,7 @@ namespace XrdCl
const char * const DefaultPlugIn = "";
const char * const DefaultReadRecovery = "true";
const char * const DefaultWriteRecovery = "true";
const char * const DefaultOpenRecovery = "true";
const char * const DefaultGlfnRedirector = "";
}

Expand Down
1 change: 1 addition & 0 deletions src/XrdCl/XrdClDefaultEnv.cc
Expand Up @@ -299,6 +299,7 @@ namespace XrdCl
REGISTER_VAR_STR( varsStr, "PlugInConfDir", DefaultPlugInConfDir );
REGISTER_VAR_STR( varsStr, "ReadRecovery", DefaultReadRecovery );
REGISTER_VAR_STR( varsStr, "WriteRecovery", DefaultWriteRecovery );
REGISTER_VAR_STR( varsStr, "OpenRecovery", DefaultOpenRecovery );
REGISTER_VAR_STR( varsStr, "GlfnRedirector", DefaultGlfnRedirector );

//--------------------------------------------------------------------------
Expand Down
34 changes: 33 additions & 1 deletion src/XrdCl/XrdClXRootDMsgHandler.cc
Expand Up @@ -1896,7 +1896,7 @@ namespace XrdCl
}
else
{
if( !status.IsFatal() )
if( !status.IsFatal() && IsRetryable( pRequest ) )
{
HandleError( RetryAtServer( pUrl ) );
return;
Expand Down Expand Up @@ -2080,4 +2080,36 @@ namespace XrdCl

return;
}

//------------------------------------------------------------------------
//! Check if it is OK to retry this request
//------------------------------------------------------------------------
bool XRootDMsgHandler::IsRetryable( Message *request )
{
std::string value;
DefaultEnv::GetEnv()->GetString( "OpenRecovery", value );
if( value == "true" ) return true;

// check if it is a mutable open (open + truncate or open + create)
ClientRequest *req = reinterpret_cast<ClientRequest*>( pRequest->GetBuffer() );
if( req->header.requestid == htons( kXR_open ) )
{
bool _mutable = ( req->open.options & htons( kXR_delete ) ) ||
( req->open.options & htons( kXR_new ) );

if( _mutable )
{
Log *log = DefaultEnv::GetLog();
log->Debug( XRootDMsg,
"[%s] Not allowed to retry open request (OpenRecovery disabled): %s.",
pUrl.GetHostId().c_str(),
pRequest->GetDescription().c_str() );
// disallow retry if it is a mutable open
return false;
}
}

return true;
}

}
8 changes: 8 additions & 0 deletions src/XrdCl/XrdClXRootDMsgHandler.hh
Expand Up @@ -375,6 +375,14 @@ namespace XrdCl
//------------------------------------------------------------------------
void HandleLocalRedirect( URL *url );

//------------------------------------------------------------------------
//! Check if it is OK to retry this request
//!
//! @param reuqest : the request in question
//! @return : true if yes, false if no
//------------------------------------------------------------------------
bool IsRetryable( Message *request );

//------------------------------------------------------------------------
// Helper struct for async reading of chunks
//------------------------------------------------------------------------
Expand Down

1 comment on commit 6ef8e30

@jmuf
Copy link
Contributor

@jmuf jmuf commented on 6ef8e30 Nov 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch seems to not be available in a release yet (checked 4.8.5)?

Please sign in to comment.