File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Hard disk full but no IOException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Hard disk full but no IOException" Watch "Hard disk full but no IOException" New topic
Author

Hard disk full but no IOException

Andi Schmidt
Greenhorn

Joined: Apr 09, 2009
Posts: 7
Hi all,

i have here a java programe which writes data using 30 threads from a DB (Oracle) into files. The workflow is:
Select unmarked data from DB
Write data to file
Mark data in DB (update) that the file was created

Last weekend the hard disk was full and nobody recognized that. I thought there is no problem and i can start the programe again (after cleaning up the hard disk) to write the unmarked data into files. After that i counted the files and the marked data from DB. I was sure that the results must be equal. I thought no data can be marked after a IOException will writing the file but i was wrong. How can this happen? There is no try/catch which catches the IOException (or other exceptions). I talked with some colleagues and they imagine that there can be problem for example with I/O-Buffers from the filesystem or operating system that sometimes no IOException was thrown.

What do you think? Is that possible? I'm sure there is no failure in the programe because it works since years without problems.

PS: Sorry again for my bad english. I'm really out of practice
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8964
    
    9

Andi Schmidt wrote:There is no try/catch which catches the IOException (or other exceptions).


There HAS to be a try/catch. File IO and database access both throw checked exceptions which must be caught or the compiler will flag them. You are not giving us all the details

Andi Schmidt wrote:I talked with some colleagues and they imagine that there can be problem for example with I/O-Buffers from the filesystem or operating system that sometimes no IOException was thrown.


I'm not aware of any such problems. Did you try searching the Java Bug Database?


[How To Ask Questions On JavaRanch]
Andi Schmidt
Greenhorn

Joined: Apr 09, 2009
Posts: 7
Joe Ess wrote:
There HAS to be a try/catch. File IO and database access both throw checked exceptions which must be caught or the compiler will flag them. You are not giving us all the details

There is a try/catch but later. I'll try to explain it with some code-snippets (it's an example!):



So it shouldn't be possible to reach markDB() when no more disk space is available. I got about 80000 IOExceptions but about in about 30 cases there wasn't thrown one (no file but marked in DB).

JDK version is 1.5.0_22-b03. More details?

Joe Ess wrote:

I'm not aware of any such problems. Did you try searching the Java Bug Database?


I can't find this problem there (and with Google). There are similar problems/bugs but not the same.
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
Maybe if you post your I/O code someone could find the problem?


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

What you're saying is that writeFile() can in certain cases fail silently. We don't know what's in writeFile() though, so we can't really diagnose it for you. It's possible that the actual Java call to create a file fails silently, but that would indicate a pretty serious bug in either the JVM or underlying OS, which seems unlikely to me. Not impossible, but unlikely.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

Is it perhaps possible that the doLogging method fails silently because the log file you're writing to is on the same full disk?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Andi Schmidt
Greenhorn

Joined: Apr 09, 2009
Posts: 7
Here the code from writeFile(); (with real name and parameters)



Rob Prime wrote:Is it perhaps possible that the doLogging method fails silently because the log file you're writing to is on the same full disk?


That's impossible. The errors are logged in DB too. And, when doLogging() was executed everything was ok, because the IOException was thrown

Btw.: The OS is Sun Solaris
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
Also zunächst einmal sollte für Variablen / Kommentare nicht gemischt Deutsch / Englisch verwenden ; - )

The code looks pretty straightforward. If there's any problem in my opinion it can only be in the JDOM Outputter. If you were able to try another method for writing the xml data (e.g. XmlSerializer or such), I'd say give it a try (just to be sure). Of course, you can always check the target file before writing the document ... just calling File#canWrite on it.
-> http://java.sun.com/javase/6/docs/api/java/io/File.html#canWrite()
Andi Schmidt
Greenhorn

Joined: Apr 09, 2009
Posts: 7
Peter Taucher wrote:Also zunächst einmal sollte für Variablen / Kommentare nicht gemischt Deutsch / Englisch verwenden ; - )


Der Code stammt nicht von mir. Die damaligen Entwickler wollten halt auch keinen Schönheitspreis gewinnen

Peter Taucher wrote:
The code looks pretty straightforward. If there's any problem in my opinion it can only be in the JDOM Outputter. If you were able to try another method for writing the xml data (e.g. XmlSerializer or such), I'd say give it a try (just to be sure). Of course, you can always check the target file before writing the document ... just calling File#canWrite on it.
-> http://java.sun.com/javase/6/docs/api/java/io/File.html#canWrite()


I think the better solution would be to check after writing if the file really exists. I'm not sure at the moment but i think canWrite(), 30 threads and a disk with no space left can make some problems too.
But to search for the problem in the JDOM Outputter is a very good idea. It's more probably to find a bug there than somewhere else.
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
Yes, you're right. Checking for file existence after writing the file may be the better solution. But nontetheless there has to be some reason why sporadically no IOException is thrown...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

Peter Taucher wrote:Also zunächst einmal sollte für Variablen / Kommentare nicht gemischt Deutsch / Englisch verwenden ; - )

Andi Schmidt wrote:Der Code stammt nicht von mir. Die damaligen Entwickler wollten halt auch keinen Schönheitspreis gewinnen

People, this is an international forum. I can read German (most of it anyway), but I'm sure I'm one of few here.
Andi Schmidt
Greenhorn

Joined: Apr 09, 2009
Posts: 7
Rob Prime wrote:
People, this is an international forum. I can read German (most of it anyway), but I'm sure I'm one of few here.


Sorry, but that was only off-topic stuff. All hard facts are in english.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

I know, otherwise I would have added a translation myself
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hard disk full but no IOException