# Logstash crashes when folder/file it is watching gets deleted and rcreated

**URL:** <https://discuss.elastic.co/t/logstash-crashes-when-folder-file-it-is-watching-gets-deleted-and-rcreated/58215>\
**Category:** Logstash\
**Created:** [August 17, 2016, 7:29am UTC](https://discuss.elastic.co/t/logstash-crashes-when-folder-file-it-is-watching-gets-deleted-and-rcreated/58215 "2016-08-17T07:29:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sameer\_srivastava](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sameer\_srivastava](https://discuss.elastic.co/u/sameer_srivastava)\
**Post date:** [August 17, 2016, 7:29am UTC](https://discuss.elastic.co/t/logstash-crashes-when-folder-file-it-is-watching-gets-deleted-and-rcreated/58215/1 "2016-08-17T07:29:21Z")

</div>

We have been using logstash 2.3.2 on windows 7 machines to index logs into elastic search. Logstash is configured to watch a folder which has only one file at the time. Using logstash's file input plugin for this purpose. Application writing logs to this folder periodically deletes the whole folder (and the file with in it) and recreates the folder and file. When we start logstash before starting the application (which generates the log), for one iteration things seem to work fine but for next iteration (directory deleted and recreated) logstash crashes with warnings about not able to open the file (which got deleted) followed by following lines

**# A fatal error has been detected by the Java Runtime Environment:**  
**#**  
**# EXCEPTION\_ACCESS\_VIOLATION (0xc0000005) at pc=0x00000000029c5c08, pid=10008, tid=8428**  
**#**  
**# JRE version: Java(TM) SE Runtime Environment (8.0\_45-b15) (build 1.8.0\_45-b15)**  
**# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode windows-amd64 compressed oops)**  
**# Problematic frame:**  
**# j com.kenai.jffi.Foreign.invokeArrayO2Int64(JJ[BLjava/lang/Object;IIILjava/lang/Object;III)J+0**  
**#**  
**# Core dump written. Default location: D:\ELK\logstash-2.3.2\hs\_err\_pid10008.mdmp**  
**#**  
**# An error report file with more information is saved as:**  
**# D:\ELK\logstash-2.3.2\hs\_err\_pid10008.log**  
**#**  
**# If you would like to submit a bug report, please visit:**  
**# [http://bugreport.java.com/bugreport/crash.jsp](http://bugreport.java.com/bugreport/crash.jsp)**  
**# The crash happened outside the Java Virtual Machine in native code.**  
**# See problematic frame for where to report the bug.**

I searched if somebody had already faced a similar issue and came across following bug already raised  
[Windows 7 issue when a files is delete in a directory raise a Native Exception](https://github.com/logstash-plugins/logstash-input-file/issues/82). As per this issue is with jruby 1.7.23 and resolved in jruby 1.7.24. Moreover this is present only in logstash 2.X and 2.3.1 whereas I am using 2.3.2.

Other suggestion was to use your own installation of jruby by setting USE\_RUBY=1. So I installed latest distribution of jruby and tried this option, but getting error while starting logstash now  
_"'ruby' is not recognized as an internal or external command, operable program or batch file."_

Is there any work around for this.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 17, 2016, 7:34am UTC](https://discuss.elastic.co/t/logstash-crashes-when-folder-file-it-is-watching-gets-deleted-and-rcreated/58215/2 "2016-08-17T07:34:18Z")

</div>

What does your config look like?

---

<div class="post-metadata">

**Author:** ![sameer\_srivastava](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sameer\_srivastava](https://discuss.elastic.co/u/sameer_srivastava)\
**Post date:** [August 17, 2016, 7:41am UTC](https://discuss.elastic.co/t/logstash-crashes-when-folder-file-it-is-watching-gets-deleted-and-rcreated/58215/3 "2016-08-17T07:41:39Z")

</div>

My conf file is on the following lines

input  
{  
file  
{  
path =\> "D:/log/\*.log"  
type =\> "log"  
start\_position =\> "end"  
ignore\_older =\> 3600  
}  
}

filter  
{  
if [type] == "log"  
{  
csv  
{  
separator =\> ","

```
		columns =>["Field1","Field2","Field3","Field4","Field5",
		"Field6","Field7","Field8","Field9","Field10","Field11","Field12"]

		add_field => { "Field13" => "%{Field2}"
		  "Field14" => "%{Field4}" 
			}
	}
	date 
	{
		match => ["Field1", "UNIX_MS"]
		timezone => "Asia/Kolkata"
	}
	
	ruby 
    {
        code => "event['Field15'] = event['Field7'].to_f/1000"
    }
	
	mutate 
	{
		remove_field => ["Field7"]
	}
}

```

}

output  
{  
if [type] == "log"  
{  
elasticsearch  
{  
action =\> "index"  
index =\> "index\_test-%{+YYYY.MM.dd}"  
hosts =\> "192.168.137.122:9201"  
flush\_size =\> 2000  
workers =\> 4  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 17, 2016, 11:00am UTC](https://discuss.elastic.co/t/logstash-crashes-when-folder-file-it-is-watching-gets-deleted-and-rcreated/58215/4 "2016-08-17T11:00:19Z")

</div>

Can you raise an issue here - [https://github.com/logstash-plugins/logstash-input-file/issues](https://github.com/logstash-plugins/logstash-input-file/issues)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:43am UTC](https://discuss.elastic.co/t/logstash-crashes-when-folder-file-it-is-watching-gets-deleted-and-rcreated/58215/5 "2017-07-06T04:43:04Z")

</div>


