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

Fix/fixInvalidLock3 #29471

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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
36 changes: 18 additions & 18 deletions source/libs/stream/src/streamMeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ int32_t streamMetaCvtDbFormat(SStreamMeta* pMeta) {
int32_t len = strlen(pMeta->path) + 32;
char* state = taosMemoryCalloc(1, len);
if (state != NULL) {
(void) snprintf(state, len, "%s%s%s", pMeta->path, TD_DIRSEP, "state");
(void)snprintf(state, len, "%s%s%s", pMeta->path, TD_DIRSEP, "state");
taosRemoveDir(state);
taosMemoryFree(state);
} else {
Expand Down Expand Up @@ -380,7 +380,7 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn,
char* tpath = taosMemoryCalloc(1, len);
TSDB_CHECK_NULL(tpath, code, lino, _err, terrno);

(void) snprintf(tpath, len, "%s%s%s", path, TD_DIRSEP, "stream");
(void)snprintf(tpath, len, "%s%s%s", path, TD_DIRSEP, "stream");
pMeta->path = tpath;

code = streamMetaOpenTdb(pMeta);
Expand All @@ -392,6 +392,22 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn,
TSDB_CHECK_CODE(code, lino, _err);
}

// set the attribute when running on Linux OS
TdThreadRwlockAttr attr;
code = taosThreadRwlockAttrInit(&attr);
TSDB_CHECK_CODE(code, lino, _err);

#ifdef LINUX
code = pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
TSDB_CHECK_CODE(code, lino, _err);
#endif

code = taosThreadRwlockInit(&pMeta->lock, &attr);
TSDB_CHECK_CODE(code, lino, _err);

code = taosThreadRwlockAttrDestroy(&attr);
TSDB_CHECK_CODE(code, lino, _err);

if ((code = streamMetaBegin(pMeta) < 0)) {
stError("vgId:%d begin trans for stream meta failed", pMeta->vgId);
goto _err;
Expand Down Expand Up @@ -431,22 +447,6 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn,

stInfo("vgId:%d open stream meta succ, latest checkpoint:%" PRId64 ", stage:%" PRId64, vgId, pMeta->chkpId, stage);

// set the attribute when running on Linux OS
TdThreadRwlockAttr attr;
code = taosThreadRwlockAttrInit(&attr);
TSDB_CHECK_CODE(code, lino, _err);

#ifdef LINUX
code = pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
TSDB_CHECK_CODE(code, lino, _err);
#endif

code = taosThreadRwlockInit(&pMeta->lock, &attr);
TSDB_CHECK_CODE(code, lino, _err);

code = taosThreadRwlockAttrDestroy(&attr);
TSDB_CHECK_CODE(code, lino, _err);

code = bkdMgtCreate(tpath, (SBkdMgt**)&pMeta->bkdChkptMgt);
TSDB_CHECK_CODE(code, lino, _err);

Expand Down
Loading