log4js-node / log4js-node/streamroller

should remove targetFile when targetFile is existing?

Open
#62 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
38
Forks
20
PR merge metrics
No merged PRs in 30d

Description

when the current file should roll,the operation is
`fs.move(sourceFilePath, targetFilePath, { overwrite: true });`
this will delete target file if it exist.
But, in the mutli process app,when set disableClustering: true, all process will do the same operation. The first write log process will rename log.log to log.log.2020-01-01-01 and renew log.log. The next write log process will rename log.log that is renewed by first process to log.log.2020-01-01-01 too and this cause log loss.

So, when target file exists, should skip remove operation?
`try {
if (fs.existsSync(targetFilePath)) {
return ;
}
await fs.move(sourceFilePath, targetFilePath, { overwrite: true });
} catch (e) { }`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the rollover path that calls fs.move(sourceFilePath, targetFilePath, { overwrite: true }) and reproduce the disableClustering: true multi-process case. Confirm the behavior when targetFilePath already exists; done means concurrent rollovers no longer overwrite the renewed log or cause log loss.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.