merge [TRAFODION-2952]
diff --git a/core/sql/cli/Cli.cpp b/core/sql/cli/Cli.cpp
index 9e14307..3d5f033 100644
--- a/core/sql/cli/Cli.cpp
+++ b/core/sql/cli/Cli.cpp
@@ -10529,9 +10529,9 @@
cliRC = cqdCliInterface->holdAndSetCQD("traf_no_dtm_xn", "ON");
}
- Lng32 numTries = 0;
+ Lng32 numTries = 0, maxRetryNum = sga->getSGRetryNum();
NABoolean isOk = FALSE;
- while ((NOT isOk) && (numTries < 10))
+ while ((NOT isOk) && (numTries < maxRetryNum))
{
if (startLocalXn)
{
@@ -10598,8 +10598,11 @@
}
numTries++;
-
- DELAY(100 + numTries*25);
+ Lng32 delayTime = 100 + numTries*25 + rand()%10;
+ if( delayTime < 1000) //MAX is 1 second
+ DELAY(delayTime);
+ else
+ DELAY( 900 + rand() % 100);
}
// could not update it after 10 tries. Return error.
diff --git a/core/sql/common/SequenceGeneratorAttributes.h b/core/sql/common/SequenceGeneratorAttributes.h
index 2220781..714f38e 100644
--- a/core/sql/common/SequenceGeneratorAttributes.h
+++ b/core/sql/common/SequenceGeneratorAttributes.h
@@ -80,7 +80,8 @@
sgCache_(psgCache),
sgNextValue_(psgNextValue),
sgEndValue_(psgEndValue),
- sgRedefTime_(psgRedefTime)
+ sgRedefTime_(psgRedefTime),
+ sgRetryNum_(100)
{}
@@ -98,7 +99,8 @@
sgCache_(0),
sgNextValue_(0),
sgEndValue_(0),
- sgRedefTime_(0)
+ sgRedefTime_(0),
+ sgRetryNum_(100)
{}
// copy ctor
@@ -117,7 +119,8 @@
sgCache_(sga.sgCache_),
sgNextValue_(sga.sgNextValue_),
sgEndValue_(sga.sgEndValue_),
- sgRedefTime_(sga.sgRedefTime_)
+ sgRedefTime_(sga.sgRedefTime_),
+ sgRetryNum_(100)
{}
// ---------------------------------------------------------------------
@@ -138,6 +141,11 @@
const Int64 &getSGNextValue() const { return sgNextValue_; }
const Int64 &getSGEndValue() const { return sgEndValue_; }
const Int64 &getSGRedefTime() const { return sgRedefTime_; }
+ const UInt32 &getSGRetryNum() const { return sgRetryNum_; }
+
+ void setSGRetryNum(const UInt32 v)
+ { sgRetryNum_ = v; }
+
void setSGStartValue(const Int64 psgStartValue)
{ sgStartValue_= psgStartValue; }
@@ -205,6 +213,7 @@
Int64 sgNextValue_;
Int64 sgEndValue_;
Int64 sgRedefTime_;
+ UInt32 sgRetryNum_;
}; // class SequenceGeneratorAttributes
#endif /* SEQUENCEGENERATORATTRIBUTES_H */
diff --git a/core/sql/exp/ExpSeqGen.cpp b/core/sql/exp/ExpSeqGen.cpp
index 849760b..203f071 100644
--- a/core/sql/exp/ExpSeqGen.cpp
+++ b/core/sql/exp/ExpSeqGen.cpp
@@ -50,6 +50,7 @@
{
fetchNewRange_ = TRUE;
cliInterfaceArr_ = NULL;
+ retryNum_ = 100; //default retry times
}
short SeqGenEntry::fetchNewRange(SequenceGeneratorAttributes &inSGA)
@@ -61,6 +62,8 @@
sga = inSGA;
if (sga.getSGCache() == 0)
sga.setSGCache(1);
+
+ sga.setSGRetryNum(getRetryNum());
cliRC = SQL_EXEC_SeqGenCliInterface(&cliInterfaceArr_, &sga);
if (cliRC < 0)
return (short)cliRC;
@@ -143,6 +146,8 @@
sgQueue()->insert((char*)&hashVal, sizeof(hashVal), sge);
}
+ sge->setRetryNum(getRetryNum());
+
return sge;
}
diff --git a/core/sql/exp/ExpSeqGen.h b/core/sql/exp/ExpSeqGen.h
index 3db3ab0..6e3f7a5 100644
--- a/core/sql/exp/ExpSeqGen.h
+++ b/core/sql/exp/ExpSeqGen.h
@@ -55,6 +55,9 @@
Int64 getSGObjectUID() { return sgUID_; }
+ void setRetryNum(UInt32 n) { retryNum_ = n; }
+ UInt32 getRetryNum() { return retryNum_ ; }
+
private:
short fetchNewRange(SequenceGeneratorAttributes &inSGA);
@@ -68,6 +71,8 @@
Int64 cachedCurrValue_;
void * cliInterfaceArr_;
+
+ UInt32 retryNum_;
};
class SequenceValueGenerator : public NABasicObject
@@ -80,11 +85,15 @@
HashQueue * sgQueue() { return sgQueue_;}
CollHeap * getHeap() { return heap_; }
+ void setRetryNum(UInt32 n) { retryNum_ = n; }
+ UInt32 getRetryNum() { return retryNum_; }
private:
CollHeap * heap_;
HashQueue * sgQueue_;
+
+ UInt32 retryNum_;
};
diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp
index 1b47f8f..b04995d 100644
--- a/core/sql/exp/exp_function.cpp
+++ b/core/sql/exp/exp_function.cpp
@@ -736,6 +736,7 @@
Space * space)
: ex_function_clause(oper_type, 1, attr, space),
sga_(sga),
+ retryNum_(),
flags_(0)
{
};
@@ -7622,6 +7623,7 @@
char * result = op_data[0];
SequenceValueGenerator * seqValGen = getExeGlobals()->seqGen();
+ seqValGen->setRetryNum(getRetryNum());
Int64 seqVal = 0;
if (isCurr())
rc = seqValGen->getCurrSeqVal(sga_, seqVal);
diff --git a/core/sql/exp/exp_function.h b/core/sql/exp/exp_function.h
index b4031ad..c67cf84 100644
--- a/core/sql/exp/exp_function.h
+++ b/core/sql/exp/exp_function.h
@@ -4055,6 +4055,10 @@
NABoolean isCurr() { return ((flags_ & IS_CURR) != 0); }
+ void setRetryNum(UInt32 n) { retryNum_ = n; }
+
+ UInt32 getRetryNum() { return retryNum_; }
+
private:
enum
{
@@ -4064,7 +4068,8 @@
SequenceGeneratorAttributes sga_;
UInt32 flags_;
- char filler1_[4];
+
+ UInt32 retryNum_;
// ---------------------------------------------------------------------
};
diff --git a/core/sql/generator/GenItemFunc.cpp b/core/sql/generator/GenItemFunc.cpp
index 4faff64..ac6d21c 100644
--- a/core/sql/generator/GenItemFunc.cpp
+++ b/core/sql/generator/GenItemFunc.cpp
@@ -2889,6 +2889,8 @@
*naTable_->getSGAttributes(),
space);
+ sv->setRetryNum(CmpCommon::getDefaultLong(TRAF_SEQUENCE_RETRY_TIMES));
+
if (cacheSize > 0)
((SequenceGeneratorAttributes*)naTable_->getSGAttributes())->setSGCache(origCacheSize);
diff --git a/core/sql/sqlcomp/DefaultConstants.h b/core/sql/sqlcomp/DefaultConstants.h
index 2098024..78c9336 100644
--- a/core/sql/sqlcomp/DefaultConstants.h
+++ b/core/sql/sqlcomp/DefaultConstants.h
@@ -2946,6 +2946,12 @@
// this is used to change cache size of sequence numbers for a session.
// It overwrites the cache size that was specified during sequence creation.
TRAF_SEQUENCE_CACHE_SIZE,
+
+ // this is used to set the retry time if two concurrent update of sequence
+ // conflict, and how many times will retry
+ // by default it is 100, when you saw error 1583, you can try to increase
+ // this settings
+ TRAF_SEQUENCE_RETRY_TIMES,
TRAF_LOAD_MAX_HFILE_SIZE,
diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp
index e56efa5..3cc6f9a 100644
--- a/core/sql/sqlcomp/nadefaults.cpp
+++ b/core/sql/sqlcomp/nadefaults.cpp
@@ -2954,6 +2954,8 @@
DD_____(TRAF_SAMPLE_TABLE_LOCATION, "/user/trafodion/sample/"),
DDint__(TRAF_SEQUENCE_CACHE_SIZE, "-1"),
+ DDint__(TRAF_SEQUENCE_RETRY_TIMES, "100"),
+
DDkwd__(TRAF_SIMILARITY_CHECK, "ROOT"),
DDkwd__(TRAF_STORE_OBJECT_DESC, "OFF"),