Merge pull request #27094 from taosdata/fix/TS-5271-3.0
fix: disable process write request when vnode is in snapshot mode
This commit is contained in:
commit
f83521b2eb
|
@ -529,6 +529,7 @@ int32_t taosGetErrSize();
|
||||||
#define TSDB_CODE_VND_META_DATA_UNSAFE_DELETE TAOS_DEF_ERROR_CODE(0, 0x0535)
|
#define TSDB_CODE_VND_META_DATA_UNSAFE_DELETE TAOS_DEF_ERROR_CODE(0, 0x0535)
|
||||||
#define TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0536)
|
#define TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0536)
|
||||||
#define TSDB_CODE_VND_ARB_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0537) // internal
|
#define TSDB_CODE_VND_ARB_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0537) // internal
|
||||||
|
#define TSDB_CODE_VND_WRITE_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0538) // internal
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||||
|
|
|
@ -473,6 +473,7 @@ struct SVnode {
|
||||||
STfs* pTfs;
|
STfs* pTfs;
|
||||||
int32_t diskPrimary;
|
int32_t diskPrimary;
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
|
bool disableWrite;
|
||||||
|
|
||||||
// Buffer Pool
|
// Buffer Pool
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
|
|
|
@ -403,6 +403,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
||||||
pVnode->msgCb = msgCb;
|
pVnode->msgCb = msgCb;
|
||||||
(void)taosThreadMutexInit(&pVnode->lock, NULL);
|
(void)taosThreadMutexInit(&pVnode->lock, NULL);
|
||||||
pVnode->blocked = false;
|
pVnode->blocked = false;
|
||||||
|
pVnode->disableWrite = false;
|
||||||
|
|
||||||
(void)tsem_init(&pVnode->syncSem, 0, 0);
|
(void)tsem_init(&pVnode->syncSem, 0, 0);
|
||||||
(void)taosThreadMutexInit(&pVnode->mutex, NULL);
|
(void)taosThreadMutexInit(&pVnode->mutex, NULL);
|
||||||
|
|
|
@ -609,7 +609,10 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, SSnapshotParam *pParam, SVSnapWriter
|
||||||
int64_t sver = pParam->start;
|
int64_t sver = pParam->start;
|
||||||
int64_t ever = pParam->end;
|
int64_t ever = pParam->end;
|
||||||
|
|
||||||
// cancel and disable all bg task
|
// disable write, cancel and disable all bg tasks
|
||||||
|
(void)taosThreadMutexLock(&pVnode->mutex);
|
||||||
|
pVnode->disableWrite = true;
|
||||||
|
(void)taosThreadMutexUnlock(&pVnode->mutex);
|
||||||
(void)vnodeCancelAndDisableAllBgTask(pVnode);
|
(void)vnodeCancelAndDisableAllBgTask(pVnode);
|
||||||
|
|
||||||
// alloc
|
// alloc
|
||||||
|
@ -742,6 +745,9 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)vnodeBegin(pVnode);
|
(void)vnodeBegin(pVnode);
|
||||||
|
(void)taosThreadMutexLock(&pVnode->mutex);
|
||||||
|
pVnode->disableWrite = false;
|
||||||
|
(void)taosThreadMutexUnlock(&pVnode->mutex);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
|
|
|
@ -518,6 +518,14 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg
|
||||||
void *pReq;
|
void *pReq;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
|
|
||||||
|
(void)taosThreadMutexLock(&pVnode->mutex);
|
||||||
|
if (pVnode->disableWrite) {
|
||||||
|
(void)taosThreadMutexUnlock(&pVnode->mutex);
|
||||||
|
vError("vgId:%d write is disabled for snapshot, version:%" PRId64, TD_VID(pVnode), ver);
|
||||||
|
return TSDB_CODE_VND_WRITE_DISABLED;
|
||||||
|
}
|
||||||
|
(void)taosThreadMutexUnlock(&pVnode->mutex);
|
||||||
|
|
||||||
if (ver <= pVnode->state.applied) {
|
if (ver <= pVnode->state.applied) {
|
||||||
vError("vgId:%d, duplicate write request. ver: %" PRId64 ", applied: %" PRId64 "", TD_VID(pVnode), ver,
|
vError("vgId:%d, duplicate write request. ver: %" PRId64 ", applied: %" PRId64 "", TD_VID(pVnode), ver,
|
||||||
pVnode->state.applied);
|
pVnode->state.applied);
|
||||||
|
|
|
@ -409,6 +409,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_ALREADY_IS_VOTER, "Vnode already is a vo
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_DIR_ALREADY_EXIST, "Vnode directory already exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_DIR_ALREADY_EXIST, "Vnode directory already exist")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_META_DATA_UNSAFE_DELETE, "Single replica vnode data will lost permanently after this operation, if you make sure this, please use drop dnode <id> unsafe to execute")
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_META_DATA_UNSAFE_DELETE, "Single replica vnode data will lost permanently after this operation, if you make sure this, please use drop dnode <id> unsafe to execute")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_ARB_NOT_SYNCED, "Vgroup peer is not synced")
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_ARB_NOT_SYNCED, "Vgroup peer is not synced")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_WRITE_DISABLED, "Vnode write is disabled for snapshot")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST,"Same with old param")
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST,"Same with old param")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue