stonedb
stonedb copied to clipboard
bug: Delete the tianmu.log file, it cannot be created automatically
Have you read the Contributing Guidelines on issues?
- [X] I have 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!
ACK
Is this feature is wanted? And is anyone working on this?
When deleted mysqld.log it will be created automatically
tianmu.log should created automatically when deleted.
这个功能无论谁做,有以下几个点需要注意:
- 不要在每次写日志操作前做日志文件是否存在的检测,这样会导致当日志文件存在时大量的对文件状态的检测函数的调用
- 正确的做法是每次写日志操作后, 检测系统调用的返回码errno,当errno给出的错误信息是文件不存在时, 创建日志文件, 并重写日志
- 当创建日志文件出错时,考虑重试策略并考虑重试几次才合理
- 当写日志失败, 内核给出的errno为文件不存在,则创建文件,为其他错误,则做详细上下文信息记录用来追踪问题
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.
Tianmu uses std::ofstream
to write logs, when mysqld starts, if no log file, the object of std::ofstream
will create one automatically.