Skip to content

Commit 0344a41

Browse files
committed
Reproduction bat files and instructions
1 parent d310c55 commit 0344a41

File tree

5 files changed

+148
-1
lines changed

5 files changed

+148
-1
lines changed

README.md

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
CONSOLE APPLICATION : fileopenwrite Project Overview
2+
====================================================
3+
## Overview
4+
Test program to verify LogStash Windows issue. This program attempts to opens a file with SharedMode=0(Exclusive lock)
5+
and writes a log message a couple times
6+
7+
The test attempts to creat/open a file with an exclusive OS lock, write to the file and close.
8+
The test then attempts to delete the file from disk.
9+
10+
## Instructions
11+
12+
To run the test first verify the logstash monolithic jar exists in the current directory
13+
14+
Run the logstash.cmd
15+
```bat
16+
c:\>cd \git\fileopenwrite
17+
c:\git\fileopenwrite>logstash.cmd
18+
```
19+
20+
Once logstash has finished opening test by entering a message in stdin.
21+
22+
Now open a new shell.
23+
24+
```bat
25+
c:\>cd \git\fileopenwrite
26+
c:\git\fileopenwrite>fileopenwrite.cmd
27+
```
28+
29+
30+
## Output from logstash.bat
31+
```bat
32+
33+
C:\git\fileopenwrite>c:
34+
35+
C:\git\fileopenwrite>cd \git\fileopenwrite
36+
37+
C:\git\fileopenwrite>rem set HOME=c:\git\fileopenwrite\sincedb
38+
39+
C:\git\fileopenwrite>rem set CloseAfterRead=true
40+
41+
C:\git\fileopenwrite>"c:\Program Files\Java\jre7\bin\java.exe" -jar logstash-1.1.10.dev-monolithic2.jar agent -f logstash.conf
42+
start
43+
{
44+
"@source" => "stdin://RI-ENG-229/",
45+
"@tags" => [],
46+
"@fields" => {},
47+
"@timestamp" => "2013-05-02T21:11:42.241Z",
48+
"@source_host" => "RI-ENG-229",
49+
"@source_path" => "/",
50+
"@message" => "start",
51+
"@type" => "human"
52+
}
53+
{
54+
"@source" => "file://RI-ENG-229/C:\\git\\fileopenwrite\\blocked.log",
55+
"@tags" => [],
56+
"@fields" => {},
57+
"@timestamp" => "2013-05-02T21:11:59.642Z",
58+
"@message" => "to write to the file.\r",
59+
"@type" => "blocked"
60+
}
61+
```
62+
63+
64+
65+
## Output from fileopenwrite.bat
66+
```bat
67+
C:\git\fileopenwrite>rm blocked.log
68+
'rm' is not recognized as an internal or external command,
69+
operable program or batch file.
70+
71+
C:\git\fileopenwrite>echo fileopenwrite will write n messages to the log file starting from position 0
72+
fileopenwrite will write n messages to the log file starting from position 0
73+
74+
C:\git\fileopenwrite>Debug\fileopenwrite.exe blocked.log 1
75+
76+
Writing 46 bytes to blocked.log.
77+
Wrote 46 bytes to blocked.log successfully.
78+
79+
C:\git\fileopenwrite>echo Now start the logstash.cmd
80+
Now start the logstash.cmd
81+
82+
C:\git\fileopenwrite>pause
83+
Press any key to continue . . .
84+
85+
C:\git\fileopenwrite>Debug\fileopenwrite.exe blocked.log 3
86+
87+
ERROR: CreateFile failed with error code 32 as follows:
88+
The process cannot access the file because it is being used by another process.
89+
90+
Terminal failure: Unable to open file "blocked.log" for write.
91+
92+
C:\git\fileopenwrite>echo Deleting the log file
93+
Deleting the log file
94+
95+
C:\git\fileopenwrite>pause
96+
Press any key to continue . . .
97+
98+
C:\git\fileopenwrite>del blocked.log
99+
C:\git\fileopenwrite\blocked.log
100+
The process cannot access the file because it is being used by another process.
101+
102+
C:\git\fileopenwrite>pause
103+
Press any key to continue . . .
104+
```
105+
106+
# Conclusion
107+
The output from the fileopenwrite.bat file clearly does not exhibit the correct behavior.
108+
The Errors
109+
110+
> ERROR: CreateFile failed with error code 32 as follows:
111+
> The process cannot access the file because it is being used by another process.
112+
113+
And
114+
> The process cannot access the file because it is being used by another process.
115+
116+
Show that log stash does not release the file reader lock until the process stops running.
117+
Rolling log appenders and loggers that attempt to obtain exclusive access will fail to operate properly when logstash monitors them.

fileopenwrite.cmd

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
rm blocked.log
2+
echo fileopenwrite will write n messages to the log file starting from position 0
3+
Debug\fileopenwrite.exe blocked.log 2
4+
echo Now start the logstash.cmd
5+
pause
6+
Debug\fileopenwrite.exe blocked.log 4
7+
8+
echo Deleting the log file
9+
pause
10+
del blocked.log
11+
pause

fileopenwrite/fileopenwrite.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include "stdafx.h"
32
#include <windows.h>
43
#include <tchar.h>

logstash.cmd

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
c:
2+
cd \git\fileopenwrite
3+
rem set HOME=c:\git\fileopenwrite\sincedb
4+
rem set CloseAfterRead=true
5+
"c:\Program Files\Java\jre7\bin\java.exe" -jar logstash-1.1.10.dev-monolithic2.jar agent -f logstash.conf
6+
pause

logstash.conf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
input {
2+
stdin {
3+
type => "human"
4+
}
5+
file {
6+
path => "C:\git\fileopenwrite\blocked.log"
7+
type => "blocked"
8+
}
9+
}
10+
output {
11+
stdout {
12+
debug => true
13+
}
14+
}

0 commit comments

Comments
 (0)