[ 
https://issues.apache.org/jira/browse/KAFKA-3904?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15352555#comment-15352555
 ] 

Ismael Juma commented on KAFKA-3904:
------------------------------------

[~h...@pinterest.com], I didn't mean to suggest that `FileChannel.open` would 
fix the issue. It's just a more direct way to get a file channel. The only 
reason we have a bunch of code that uses `RandomAccessFile` for this is that we 
previously could not use Java 7. The issue you saw with some implementations 
that don't support it isn't really an issue when dealing with a normal file 
system path. It's just for custom file system implementations (eg 
ZipFileSystemProvider, etc.).

Using `RandomFileAccess` is also not great because it holds a reference to the 
file descriptor, which can delay resource release.

> File descriptor leaking (Too many open files) for long running stream process
> -----------------------------------------------------------------------------
>
>                 Key: KAFKA-3904
>                 URL: https://issues.apache.org/jira/browse/KAFKA-3904
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>            Reporter: Henry Cai
>            Assignee: Henry Cai
>              Labels: architecture, newbie
>
> I noticed when my application was running long (> 1 day), I will get 'Too 
> many open files' error.
> I used 'lsof' to list all the file descriptors used by the process, it's over 
> 32K, but most of them belongs to the .lock file, e.g. this same lock file 
> shows 2700 times.
> I looked at the code, I think the problem is in:
>     File lockFile = new File(stateDir, ProcessorStateManager.LOCK_FILE_NAME);
>     FileChannel channel = new RandomAccessFile(lockFile, "rw").getChannel();
> Each time new RandomAccessFile is called, a new fd will be created, we 
> probably should either close or reuse this RandomAccessFile object.
> lsof result:
> java    14799 hcai *740u   REG                9,0        0 2415928585 
> /mnt/stream/join/rocksdb/ads-demo-30/0_16/.lock
> java    14799 hcai *743u   REG                9,0        0 2415928585 
> /mnt/stream/join/rocksdb/ads-demo-30/0_16/.lock
> java    14799 hcai *746u   REG                9,0        0 2415928585 
> /mnt/stream/join/rocksdb/ads-demo-30/0_16/.lock
> java    14799 hcai *755u   REG                9,0        0 2415928585 
> /mnt/stream/join/rocksdb/ads-demo-30/0_16/.lock
> hcai@teststream02001:~$ lsof -p 14799 | grep lock | grep 0_16  | wc
>    2709   24381  319662



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to