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

Filestream input locks files in Windows #29113

Closed
Sergi-GC opened this issue Nov 24, 2021 · 3 comments · Fixed by #29180
Closed

Filestream input locks files in Windows #29113

Sergi-GC opened this issue Nov 24, 2021 · 3 comments · Fixed by #29180
Assignees
Labels
backport-v7.15.0 Automated backport with mergify backport-v7.16.0 Automated backport with mergify backport-v8.0.0 Automated backport with mergify bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.1.0

Comments

@Sergi-GC
Copy link

  • Version: v7.13.1 and v7.15.1
  • Operating System: Windows
  • Description:

When using the Filestream input in Windows, Filebeat locks the files it's monitoring and prevents other processes from renaming or moving the files.

This has been reproduced in Windows Server 2016, Windows 10 Enterprise and in Windows 10 Home environment.

Error in Windows Server 2016:
filebeat_filstream_locked_error

Error in Windows 10 Home:
windows-10-test

This issue does not reproduce in MacOS.
And also does not happen with the Log input.

  • Steps to reproduce:

Case 1: Commenting out the close inactive settings for both inputs

Settings:

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - C:\logs\this_file_is_not_locked.log

  clean_removed: true
  close_renamed: true
 #close_inactive: 1m
  scan_frequency: 10s

- type: filestream
  enabled: true
  paths:
    - C:\logs\this_file_is_locked.log

  clean_removed: true
  close.on_state_change.removed: true
  close.on_state_change.renamed: true
  #close.on_state_change.inactive: 1m
  prospector.scanner.check_interval: 10s

Results:

  • The file this_file_is_not_locked can be renamed/deleted/moved any time since the moment Filebeat is started.
  • The file this_file_is_locked cannot be renamed/deleted/moved since the moment Filebeat is started.

Case 2: Setting close inactive settings to 1min

Settings:

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - C:\logs\this_file_is_not_locked.log

  clean_removed: true
  close_renamed: true
  close_inactive: 1m
  scan_frequency: 10s

- type: filestream
  enabled: true
  paths:
    - C:\logs\this_file_is_locked.log
   
  clean_removed: true
  close.on_state_change.removed: true
  close.on_state_change.renamed: true
  close.on_state_change.inactive: 1m
  prospector.scanner.check_interval: 10s

Results:

  • The file this_file_is_not_locked can be renamed/deleted/moved any time since the moment Filebeat is started.
  • The file this_file_is_locked cannot be renamed/deleted/moved for about 1m since the moment Filebeat is started. After 1 min the file can be renamed/deleted/moved.

Case 3: Commenting out all the close/clean settings

Settings:

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - C:\logs\this_file_is_not_locked.log

  #clean_removed: true
  #close_renamed: true
  #close_inactive: 1m
  scan_frequency: 10s

- type: filestream
  enabled: true
  paths:
    - C:\logs\this_file_is_locked.log
   
  #clean_removed: true
  #close.on_state_change.removed: true
  #close.on_state_change.renamed: true
  #close.on_state_change.inactive: 1m
  prospector.scanner.check_interval: 10s

Results:

  • The file this_file_is_not_locked can be renamed/deleted/moved any time since the moment Filebeat is started.

  • The file this_file_is_locked cannot be renamed/deleted/moved for about 1m since the moment Filebeat is started.

  • Logs from each scenario:
    filebeat_case_1.log
    filebeat_case_2.log
    filebeat_case_3.log

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Nov 24, 2021
@jlind23 jlind23 added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Nov 24, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 24, 2021
@jlind23 jlind23 added 8.1-candidate needs_team Indicates that the issue/PR needs a Team:* label Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team and removed Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Nov 24, 2021
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 24, 2021
@jlind23 jlind23 added the bug label Nov 24, 2021
@kvch kvch self-assigned this Nov 29, 2021
kvch added a commit to kvch/beats that referenced this issue Nov 29, 2021
mergify bot pushed a commit that referenced this issue Nov 29, 2021
mergify bot pushed a commit that referenced this issue Nov 29, 2021
mergify bot pushed a commit that referenced this issue Nov 29, 2021
@jlind23 jlind23 added backport-v7.15.0 Automated backport with mergify backport-v7.16.0 Automated backport with mergify backport-v8.0.0 Automated backport with mergify labels Nov 29, 2021
kvch added a commit that referenced this issue Nov 30, 2021
kvch added a commit that referenced this issue Nov 30, 2021
kvch added a commit that referenced this issue Nov 30, 2021
@amolnater-qasource
Copy link

amolnater-qasource commented Mar 4, 2022

Hi @kvch
We have revalidated this issue on 8.1 BC-6 Kibana self-managed environment.
HOST: AWS-Windows 2016 Server

Build details:
BUILD: 50485
COMMIT: 4aaeda23aea9c3bf29698878c70a0107ea3c1659
Artifact Link: https://staging.elastic.co/8.1.0-6b89df21/summary-8.1.0.html

We had below observations:

Case 1: Commenting out the close inactive settings for both inputs

We were able to move, rename and delete both locked_file.log and unlocked_file.log.

Case 2: Setting close inactive settings to 1min

We were able to move, rename and delete both locked_file.log and unlocked_file.log.

Case 3: Commenting out all the close/clean settings

We were able to move, rename and delete both locked_file.log and unlocked_file.log.

Hence, this issue is not reproducible now.

For reference we have used below filebeat.yml and log files.
filebeat.zip
[Necessary changes were made as per different cases]
unlocked_file.log
locked_file.log

Please let us know if this is the required result and let us know if we are missing anything.

Thanks!!

@amolnater-qasource
Copy link

FYI @jlind23

leweafan pushed a commit to leweafan/beats that referenced this issue Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.15.0 Automated backport with mergify backport-v7.16.0 Automated backport with mergify backport-v8.0.0 Automated backport with mergify bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.1.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants