我的项目用了 zlog , 所有的工作很好
但是会出现
01-02 18:07:28 WARN (3363245:rotater.c:467) pthread_mutex_trylock fail, as lock_mutex is locked by other threads
01-02 18:07:28 WARN (3363245:rotater.c:510) zlog_rotater_trylock fail, maybe lock by other process or threads
常用进程 每个约3个线程,
系统 Ubuntu 20, 大约是什么原因呢
而且这个一旦发生, 似乎就再也无法停下了, 哪怕我重启所有进程似乎也似乎无法rotate
BTW
static int zlog_rotater_trylock(zlog_rotater_t *a_rotater)
{
int rc;
rc = pthread_mutex_trylock(&(a_rotater->lock_mutex));
if (rc == EBUSY) {
zc_warn("pthread_mutex_trylock fail, as lock_mutex is locked by other threads");
return -1;
} else if (rc != 0) {
zc_error("pthread_mutex_trylock fail, rc[%d]", rc);
return -1;
}
a_rotater->lock_fd = lock_file(a_rotater->lock_file);
if (a_rotater->lock_fd == INVALID_LOCK_FD) {
return -1;
}
return 0;
}
zlog_rotate 的时候尝试 trylock rotate 文件锁
但是失败后会直接返回
if (zlog_rotater_trylock(a_rotater)) {
zc_warn("zlog_rotater_trylock fail, maybe lock by other process or threads");
return 0;
}
我的项目用了 zlog , 所有的工作很好 但是会出现 01-02 18:07:28 WARN (3363245:rotater.c:467) pthread_mutex_trylock fail, as lock_mutex is locked by other threads 01-02 18:07:28 WARN (3363245:rotater.c:510) zlog_rotater_trylock fail, maybe lock by other process or threads
很多,然后log文件和这个 zlog.error.log 文件会不断+大
工作环境是 1个守护进程拉起 多个子进程(8-10) 守护进程和所有子进程 同时指向一个config , 并默认的用这个config作为rotate的文件锁 所有的进程 指向同一个log文件路径
常用进程 每个约3个线程, 系统 Ubuntu 20, 大约是什么原因呢 而且这个一旦发生, 似乎就再也无法停下了, 哪怕我重启所有进程似乎也似乎无法rotate BTW static int zlog_rotater_trylock(zlog_rotater_t *a_rotater) { int rc;
} zlog_rotate 的时候尝试 trylock rotate 文件锁 但是失败后会直接返回 if (zlog_rotater_trylock(a_rotater)) { zc_warn("zlog_rotater_trylock fail, maybe lock by other process or threads"); return 0; }
如果情况是我线程锁+成功 但是 文件锁失败的情况 是不是会导致 线程就直接锁死无法释放? 还是我的理解有错误?