Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 5 feature rondb 753 ttl feature rebase 24.10 #605

Open
wants to merge 7 commits into
base: 24.10-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mysql-test/ttl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3195,6 +3195,9 @@ def case(num):
"col_c INT, "
"PRIMARY KEY(col_a)) "
"ENGINE = NDB, "
"COMMENT=\"NDB_TABLE=TTL=66@col_b\"")
time.sleep(5)
cur.execute("ALTER TABLE test.sz "
"COMMENT=\"NDB_TABLE=TTL=10@col_b\"")
except Exception as e:
print(f"Create DB/TABLE failed: {e}")
Expand Down
15 changes: 13 additions & 2 deletions storage/ndb/include/kernel/signaldata/LqhKey.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ class LqhKeyReq {
*/
static void setTTLIgnoreFlag(UintR &requestInfo, UintR val);
static UintR getTTLIgnoreFlag(const UintR &requestInfo);
static void setTTLOnlyExpiredFlag(UintR &requestInfo, UintR val);
static UintR getTTLOnlyExpiredFlag(const UintR &requestInfo);

enum RequestInfo {
RI_KEYLEN_SHIFT = 0,
Expand All @@ -244,8 +246,8 @@ class LqhKeyReq {
*/
RI_TTL_IGNORE_SHIFT = 6,
RI_INTERPRETED_INSERT_SHIFT = 7,
RI_TTL_ONLY_EXPIRED_SHIFT = 8,
/* Currently unused */
RI_CLEAR_SHIFT8 = 8,
RI_CLEAR_SHIFT9 = 9,

RI_LAST_REPL_SHIFT = 10,
Expand Down Expand Up @@ -646,7 +648,7 @@ inline UintR LqhKeyReq::getDisableFkConstraints(const UintR &requestInfo) {
}

inline UintR LqhKeyReq::getLongClearBits(const UintR &requestInfo) {
const Uint32 mask = (1 << RI_CLEAR_SHIFT8) | (1 << RI_CLEAR_SHIFT9);
const Uint32 mask = (1 << RI_CLEAR_SHIFT9);

return (requestInfo & mask);
}
Expand Down Expand Up @@ -696,6 +698,15 @@ inline UintR LqhKeyReq::getTTLIgnoreFlag(const UintR & requestInfo){
return (requestInfo >> RI_TTL_IGNORE_SHIFT) & 1;
}

inline void LqhKeyReq::setTTLOnlyExpiredFlag(UintR &requestInfo, UintR val){
ASSERT_BOOL(val, "LqhKeyReq::setTTLOnlyExpiredFlag");
requestInfo |= (val << RI_TTL_ONLY_EXPIRED_SHIFT);
}

inline UintR LqhKeyReq::getTTLOnlyExpiredFlag(const UintR & requestInfo){
return (requestInfo >> RI_TTL_ONLY_EXPIRED_SHIFT) & 1;
}

inline Uint32 table_version_major_lqhkeyreq(Uint32 x) {
// LQHKEYREQ only contains 16-bit schema version...
return x & 0xFFFF;
Expand Down
21 changes: 20 additions & 1 deletion storage/ndb/include/kernel/signaldata/ScanFrag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class ScanFragReq {

static void setTTLIgnoreFragFlag(Uint32 & requestInfo, Uint32 val);
static Uint32 getTTLIgnoreFragFlag(const Uint32 & requestInfo);

static void setTTLOnlyExpiredFragFlag(Uint32 & requestInfo, Uint32 val);
static Uint32 getTTLOnlyExpiredFragFlag(const Uint32 & requestInfo);
};

/*
Expand Down Expand Up @@ -348,11 +351,12 @@ class ScanFragNextReq {
* q = Query thread flag - 1 Bit 22
* g = Aggregation flag - 1 Bit 23
* I = TTL ignore flag - 1 Bit 24
* e = TTL only expired flag - 1 Bit 25
*
* 1111111111222222222233
* 01234567890123456789012345678901
* rrcdlxhkrztppppaaaaaaaaaaaaaaaa Short variant ( < 6.4.0)
* rrcdlxhkrztppppCsaim gI Long variant (6.4.0 +)
* rrcdlxhkrztppppCsaim gIe Long variant (6.4.0 +)
*/
#define SF_LOCK_MODE_SHIFT (5)
#define SF_LOCK_MODE_MASK (1)
Expand Down Expand Up @@ -385,6 +389,7 @@ class ScanFragNextReq {
#define SF_QUERY_THREAD_SHIFT (22)
#define SF_AGGREGATION_SHIFT (23)
#define SF_TTL_IGNORE_SHIFT (24)
#define SF_TTL_ONLY_EXPIRED_SHIFT (25)

inline Uint32 ScanFragReq::getLockMode(const Uint32 &requestInfo) {
return (requestInfo >> SF_LOCK_MODE_SHIFT) & SF_LOCK_MODE_MASK;
Expand Down Expand Up @@ -604,6 +609,20 @@ ScanFragReq::getTTLIgnoreFragFlag(const Uint32 & requestInfo) {
return (requestInfo >> SF_TTL_IGNORE_SHIFT) & 1;
}

inline
void
ScanFragReq::setTTLOnlyExpiredFragFlag(Uint32 & requestInfo, UintR val) {
ASSERT_BOOL(val, "ScanFragReq::setTTLOnlyExpiredFlag");
requestInfo= (requestInfo & ~(1 << SF_TTL_ONLY_EXPIRED_SHIFT)) |
(val << SF_TTL_ONLY_EXPIRED_SHIFT);
}

inline
Uint32
ScanFragReq::getTTLOnlyExpiredFragFlag(const Uint32 & requestInfo) {
return (requestInfo >> SF_TTL_ONLY_EXPIRED_SHIFT) & 1;
}

/**
* Request Info (SCAN_NEXTREQ)
*
Expand Down
19 changes: 18 additions & 1 deletion storage/ndb/include/kernel/signaldata/ScanTab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class ScanTabReq {
static Uint8 getReadCommittedBaseFlag(const UintR &requestInfo);
static Uint32 getMultiFragFlag(const Uint32 &requestInfo);
static Uint32 getTTLIgnoreFlag(const Uint32 &requestInfo);
static Uint32 getTTLOnlyExpiredFlag(const Uint32 &requestInfo);

/**
* Set:ers for requestInfo
Expand All @@ -147,6 +148,7 @@ class ScanTabReq {
static void setReadCommittedBaseFlag(Uint32 &requestInfo, Uint32 val);
static void setMultiFragFlag(Uint32 &requestInfo, Uint32 val);
static void setTTLIgnoreFlag(Uint32 &requestInfo, Uint32 val);
static void setTTLOnlyExpiredFlag(Uint32 &requestInfo, Uint32 val);
};

/**
Expand Down Expand Up @@ -177,11 +179,12 @@ class ScanTabReq {
f = 4 word conf - 1 Bit 29
R = Read Committed base - 1 Bit 30
I = IgnoreTTL - 1 Bit 3
e = TTL only expired - 1 Bit 4

1111111111222222222233
01234567890123456789012345678901
pppppppplnhcktzxbbbbbbbbbbdjafR
I g
Ie g
*/

#define PARALLEL_SHIFT (0)
Expand Down Expand Up @@ -230,6 +233,7 @@ class ScanTabReq {
#define SCAN_MULTI_FRAG_SHIFT (31)

#define SCAN_TTL_IGNORE_SHIFT (3)
#define SCAN_TTL_ONLY_EXPIRED_SHIFT (4)

inline Uint8 ScanTabReq::getReadCommittedBaseFlag(const UintR &requestInfo) {
return (Uint8)((requestInfo >> SCAN_READ_COMMITTED_BASE_SHIFT) & 1);
Expand Down Expand Up @@ -436,6 +440,19 @@ ScanTabReq::setTTLIgnoreFlag(UintR & requestInfo, Uint32 flag) {
requestInfo= (requestInfo & ~(1 << SCAN_TTL_IGNORE_SHIFT)) |
(flag << SCAN_TTL_IGNORE_SHIFT);
}
inline
UintR
ScanTabReq::getTTLOnlyExpiredFlag(const UintR & requestInfo) {
return (requestInfo >> SCAN_TTL_ONLY_EXPIRED_SHIFT) & 1;
}

inline
void
ScanTabReq::setTTLOnlyExpiredFlag(UintR & requestInfo, Uint32 flag) {
ASSERT_BOOL(flag, "TcKeyReq::setTTLOnlyExpiredFlag");
requestInfo= (requestInfo & ~(1 << SCAN_TTL_ONLY_EXPIRED_SHIFT)) |
(flag << SCAN_TTL_ONLY_EXPIRED_SHIFT);
}
/**
*
* SENDER: Dbtc
Expand Down
17 changes: 17 additions & 0 deletions storage/ndb/include/kernel/signaldata/TcKeyReq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ class TcKeyReq {
*/
static void setTTLIgnoreFlag(UintR &requestInfo, UintR val);
static UintR getTTLIgnoreFlag(const UintR &requestInfo);
static void setTTLOnlyExpiredFlag(UintR &requestInfo, UintR val);
static UintR getTTLOnlyExpiredFlag(const UintR &requestInfo);
};

/**
Expand Down Expand Up @@ -439,6 +441,7 @@ class TcKeyReq {
*/
#define TC_TTL_IGNORE_SHIFT (26)
#define INTERPRETED_INSERT_SHIFT (27)
#define TC_TTL_ONLY_EXPIRED_SHIFT (28)

/**
* Scan Info
Expand Down Expand Up @@ -815,6 +818,20 @@ TcKeyReq::getTTLIgnoreFlag(const UintR & requestInfo)
return (requestInfo >> TC_TTL_IGNORE_SHIFT) & 1;
}

inline
void
TcKeyReq::setTTLOnlyExpiredFlag(UintR & requestInfo, UintR flag){
ASSERT_BOOL(flag, "TcKeyReq::setTTLOnlyExpiredFlag");
requestInfo |= (flag << TC_TTL_ONLY_EXPIRED_SHIFT);
}

inline
UintR
TcKeyReq::getTTLOnlyExpiredFlag(const UintR & requestInfo)
{
return (requestInfo >> TC_TTL_ONLY_EXPIRED_SHIFT) & 1;
}

#undef JAM_FILE_ID

#endif
2 changes: 1 addition & 1 deletion storage/ndb/include/ndbapi/NdbDictionary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ class NdbDictionary {
/*
* Is TTL enabled
*/
bool isTTLEnabled();
bool isTTLEnabled() const;

private:
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
Expand Down
6 changes: 4 additions & 2 deletions storage/ndb/include/ndbapi/NdbOperation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,8 @@ class NdbOperation {
*/
OO_TTL_IGNORE = 0x8000,
OO_INTERPRETED_INSERT = 0x10000,
OO_DIRTY_FLAG = 0x20000
OO_DIRTY_FLAG = 0x20000,
OO_TTL_ONLY_EXPIRED = 0x40000
};

/* An operation-specific abort option.
Expand Down Expand Up @@ -1572,7 +1573,8 @@ class NdbOperation {
OF_NOWAIT = 0x20,
OF_BLOB_PART_READ = 0x40,
OF_REPLICA_APPLIER = 0x80,
OF_TTL_IGNORE = 0x100
OF_TTL_IGNORE = 0x100,
OF_TTL_ONLY_EXPIRED = 0x200
};
/*
* Zart
Expand Down
6 changes: 4 additions & 2 deletions storage/ndb/include/ndbapi/NdbScanOperation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ class NdbScanOperation : public NdbOperation {
It is enabled by default for scans using LM_Exclusive, but must be
explicitly specified to enable the taking-over of LM_Read locks.
*/
SF_KeyInfo = 1
SF_KeyInfo = 1,
SF_OnlyExpiredScan = (4 << 16)
};

/*
Expand Down Expand Up @@ -163,7 +164,8 @@ class NdbScanOperation : public NdbOperation {
SO_INTERPRETED = 0x20,
SO_CUSTOMDATA = 0x40,
SO_PART_INFO = 0x80,
SO_TTL_IGNORE = 0x100
SO_TTL_IGNORE = 0x100,
SO_TTL_ONLY_EXPIRED = 0x200
};

/* Flags controlling scan behaviour
Expand Down
2 changes: 2 additions & 0 deletions storage/ndb/ndbapi-examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ADD_EXECUTABLE(ndb_ndbapi_simple_dual ndbapi_simple_dual/main.cpp)
ADD_EXECUTABLE(ndb_ndbapi_simple_index ndbapi_simple_index/main.cpp)
ADD_EXECUTABLE(ndb_ndbapi_agg ndbapi_agg/ndbapi_agg.cpp)
ADD_EXECUTABLE(ndb_ndbapi_agg_update ndbapi_agg/update.cpp)
ADD_EXECUTABLE(ndb_ndbapi_ttl_purge ndbapi_ttl_purge/ttl_purge_demo.cpp)

# MgmApi examples
ADD_EXECUTABLE(ndb_mgmapi_logevent mgmapi_logevent/main.cpp)
Expand Down Expand Up @@ -86,6 +87,7 @@ SET(EXAMPLES
ndb_ndbapi_simple_index
ndb_ndbapi_agg
ndb_ndbapi_agg_update
ndb_ndbapi_ttl_purge

ndb_mgmapi_logevent
ndb_mgmapi_logevent2
Expand Down
Loading