stonedb icon indicating copy to clipboard operation
stonedb copied to clipboard

bug: Delete the tianmu.log file, it cannot be created automatically

Open davidshiz opened this issue 1 year ago • 6 comments

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • [X] I confirm there is no existing issue for this

Describe the problem

../install/log/tianmu.log

Expected behavior

should automatically create log file

How To Reproduce

No response

Environment

No response

Are you interested in submitting a PR to solve the problem?

  • [ ] Yes, I will!

davidshiz avatar Apr 17 '23 03:04 davidshiz

ACK

chenshengjiang avatar May 04 '23 02:05 chenshengjiang

Is this feature is wanted? And is anyone working on this?

duanjr avatar May 11 '23 08:05 duanjr

When deleted mysqld.log it will be created automatically
tianmu.log should created automatically when deleted.

davidshiz avatar May 29 '23 07:05 davidshiz

这个功能无论谁做,有以下几个点需要注意:

  1. 不要在每次写日志操作前做日志文件是否存在的检测,这样会导致当日志文件存在时大量的对文件状态的检测函数的调用
  2. 正确的做法是每次写日志操作后, 检测系统调用的返回码errno,当errno给出的错误信息是文件不存在时, 创建日志文件, 并重写日志
  3. 当创建日志文件出错时,考虑重试策略并考虑重试几次才合理
  4. 当写日志失败, 内核给出的errno为文件不存在,则创建文件,为其他错误,则做详细上下文信息记录用来追踪问题

adofsauron avatar May 29 '23 07:05 adofsauron

If delete tianmu.log while mysqld is running, it will create tianmu.log automatically after restarting mysqld, same sa mysqld.log. When mysqld is running, mysqld always keeps the log files open, it will not detect if the log files exist or not until it start next time. So we think it is not a bug.

chenshengjiang avatar May 31 '23 09:05 chenshengjiang

Tianmu uses std::ofstream to write logs, when mysqld starts, if no log file, the object of std::ofstream will create one automatically.

chenshengjiang avatar May 31 '23 12:05 chenshengjiang