logstash icon indicating copy to clipboard operation
logstash copied to clipboard

NotImplementedError: block device detection unsupported or native support failed to load

Open mattstibbs opened this issue 11 years ago • 60 comments

Issue

I am encountering the following error when trying to use the file input to watch /var/log/syslog and /var/log/auth.log

I have run the following on the log files:

setfacl -m u:logstash:r /var/log/{syslog,auth.log}

The following exception stack trace is from /var/log/logstash/logstash.err

NotImplementedError: block device detection unsupported or native support failed to load
       blockdev? at org/jruby/RubyFileTest.java:67
         device? at /opt/logstash/vendor/bundle/jruby/1.9/gems/filewatch-0.6.2/lib/filewatch/helper.rb:67
  _sincedb_write at /opt/logstash/vendor/bundle/jruby/1.9/gems/filewatch-0.6.2/lib/filewatch/tail.rb:230
   sincedb_write at /opt/logstash/vendor/bundle/jruby/1.9/gems/filewatch-0.6.2/lib/filewatch/tail.rb:203
        teardown at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-file-0.1.9/lib/logstash/inputs/file.rb:151
     inputworker at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0.rc3-java/lib/logstash/pipeline.rb:203
     synchronize at org/jruby/ext/thread/Mutex.java:149
     inputworker at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0.rc3-java/lib/logstash/pipeline.rb:203
     start_input at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0.rc3-java/lib/logstash/pipeline.rb:171

If I run interactively using sudo -u logstash /opt/logstash/bin/logstash agent -f /etc/logstash/conf.d/ --verbose

I get the same exception stack trace plus this:

The error reported is:
  Bad file descriptor - Bad file descriptor

I have a number of file inputs in the pipeline, but it seems only be this file input that causes a problem. Removing this file input allows it to start fine.

Environment Details

root@logstash1:/# lsb_release -d
Description:    Ubuntu 14.04.1 LTS
root@logstash1:/# /opt/logstash/bin/logstash -V
logstash 1.5.0-rc3
root@logstash1:/# java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

mattstibbs avatar Apr 28 '15 21:04 mattstibbs

I have now significantly simplified the pipeline to try and narrow this problem down. Pipeline is now:

input {
  file {
    sincedb_path => [ "/var/tmp/log.sincedb" ]
    path => [ "/var/tmp/log.log" ]
    type => "syslog"
  }
}
output {
  stdout { codec => rubydebug }
}

I have also changed permissions on /var/tmp with:

sudo chmod 777 -R /var/tmp/

Running logstash with the following still generates the original error:

sudo -u logstash /opt/logstash/bin/logstash agent -f /etc/logstash/conf.d/ --verbose

Stuck as to where to go next!

mattstibbs avatar Apr 29 '15 08:04 mattstibbs

Having started with a fresh install of Ubuntu, I am getting the same problem but am now noticing the following error intermittently as well as the reported error.

I can't find any pattern as to what causes which to appear, although it seems that if I only use RC2 I only get the below error (and not the block device error)

NotImplementedError: stat.st_dev unsupported or native support failed to load
       dev_major at org/jruby/RubyFileStat.java:188
  _discover_file at /opt/logstash/vendor/bundle/jruby/1.9/gems/filewatch-0.6.1/lib/filewatch/watch.rb:150
            each at org/jruby/RubyArray.java:1613
  _discover_file at /opt/logstash/vendor/bundle/jruby/1.9/gems/filewatch-0.6.1/lib/filewatch/watch.rb:132
           watch at /opt/logstash/vendor/bundle/jruby/1.9/gems/filewatch-0.6.1/lib/filewatch/watch.rb:38
            tail at /opt/logstash/vendor/bundle/jruby/1.9/gems/filewatch-0.6.1/lib/filewatch/tail.rb:68
             run at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-file-0.1.6/lib/logstash/inputs/file.rb:133
            each at org/jruby/RubyArray.java:1613
             run at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-file-0.1.6/lib/logstash/inputs/file.rb:133
     inputworker at /opt/logstash/lib/logstash/pipeline.rb:174
     start_input at /opt/logstash/lib/logstash/pipeline.rb:168

Also confirmed not an issue when reverting to logstash-1.4.2 using same config on same machine

mattstibbs avatar Apr 29 '15 15:04 mattstibbs

@mattstibbs I am unable to reproduce this :( It is weird because we have many folks hitting this issue -- https://github.com/elastic/logstash/issues/2962, https://github.com/elastic/logstash/issues/3033

ubuntu@ip-10-0-1-9:/opt/logstash$ lsb_release -d
Description:    Ubuntu 14.04.1 LTS
ubuntu@ip-10-0-1-9:/opt/logstash$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
ubuntu@ip-10-0-1-9:/opt/logstash$ bin/logstash version
logstash 1.5.0-rc3
ubuntu@ip-10-0-1-9:/opt/logstash$ bin/logstash -e 'input { file { path => "/var/log/syslog" start_position => "beginning" } }'
Logstash startup completed
{
       "message" => "Apr 30 07:00:49 ip-10-0-1-9 dhclient: DHCPREQUEST of 10.0.1.9 on eth0 to 10.0.1.1 port 67 (xid=0x54d2a924)",
      "@version" => "1",
    "@timestamp" => "2015-04-30T21:22:40.079Z",
          "host" => "ip-10-0-1-9",
          "path" => "/var/log/syslog"
}

suyograo avatar Apr 30 '15 21:04 suyograo

@suyograo :(

All my previous tests have been on digitalocean droplets. Have just followed below steps and am getting exactly same error:

  1. Download Ubuntu 14.04.2 Server iso from http://www.ubuntu.com/download/server
  2. Create standard Ubuntu install using VirtualBox (RAM 512Mb, HDD 16GB).
  3. During startup create a user as instructed and then log into machine as that user
  4. Run following commands in order:
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get -y install oracle-java8-installer
reboot

wget http://download.elastic.co/logstash/logstash/packages/debian/logstash_1.5.0-rc3-1_all.deb
sudo dpkg -i logstash_1.5.0-rc3-1_all.deb
reboot

cd /opt/logstash
sudo bin/logstash -e 'input { file { path => "/var/log/syslog" start_position => "beginning" } }'
  • Ubuntu 14.04.2 LTS
  • java version "1.8.0_45"
  • logstash 1.5.0-rc3

mattstibbs avatar May 01 '15 11:05 mattstibbs

@mattstibbs Thanks, I was able to reproduce -- we'll look into this.

ubuntu@ip-10-0-1-10:/opt/logstash$ lsb_release -d
Description:    Ubuntu 14.04.2 LTS
ubuntu@ip-10-0-1-10:/opt/logstash$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
ubuntu@ip-10-0-1-10:/opt/logstash$ bin/logstash version
logstash 1.5.0-rc3
ubuntu@ip-10-0-1-10:/opt/logstash$

suyograo avatar May 01 '15 21:05 suyograo

@jsvd the device check was added in https://github.com/jordansissel/ruby-filewatch/pull/54. Can you take a look please?

suyograo avatar May 01 '15 22:05 suyograo

I tried using Oracle Java 7 or Java 8 from the repo @mattstibbs suggested in an ec2 ubuntu 14.04 instance:

$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
$ bin/logstash irb
irb(main):001:0> File.blockdev? "/"
NotImplementedError: block device detection unsupported or native support failed to load
    from org/jruby/RubyFileTest.java:67:in `blockdev?'
    from (irb):1:in `evaluate'
    from org/jruby/RubyKernel.java:1107:in `eval'
    from org/jruby/RubyKernel.java:1507:in `loop'
    from org/jruby/RubyKernel.java:1270:in `catch'
    from org/jruby/RubyKernel.java:1270:in `catch'
    from /home/ubuntu/logstash-1.5.0-rc3/lib/logstash/runner.rb:77:in `run'
    from org/jruby/RubyProc.java:271:in `call'
    from /home/ubuntu/logstash-1.5.0-rc3/lib/logstash/runner.rb:131:in `run'
    from org/jruby/RubyProc.java:271:in `call'
    from /home/ubuntu/logstash-1.5.0-rc3/vendor/bundle/jruby/1.9/gems/stud-0.0.19/lib/stud/task.rb:12:in `initialize'
irb(main):002:0> 

Then tried stock openjdk 7:

$ java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
(reverse-i-search)`': ^C
$ bin/logstash irb
irb(main):001:0> File.blockdev? "/"
=> false

So it seems to be an issue with oracle jvm, looking deeper into this..

jsvd avatar May 06 '15 11:05 jsvd

Same happens for Stat#dev_minor

Oracle JDK 7

$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
$ bin/logstash irb
irb(main):001:0> File::Stat.new("/var/tmp/log").dev_minor
NotImplementedError: stat.st_dev unsupported or native support failed to load
    from org/jruby/RubyFileStat.java:193:in `dev_minor'
    from (irb):3:in `evaluate'
    from org/jruby/RubyKernel.java:1107:in `eval'
    from org/jruby/RubyKernel.java:1507:in `loop'
    from org/jruby/RubyKernel.java:1270:in `catch'
    from org/jruby/RubyKernel.java:1270:in `catch'
    from /home/ubuntu/logstash-1.5.0-rc3/lib/logstash/runner.rb:77:in `run'
    from org/jruby/RubyProc.java:271:in `call'
    from /home/ubuntu/logstash-1.5.0-rc3/lib/logstash/runner.rb:131:in `run'
    from org/jruby/RubyProc.java:271:in `call'
    from /home/ubuntu/logstash-1.5.0-rc3/vendor/bundle/jruby/1.9/gems/stud-0.0.19/lib/stud/task.rb:12:in `initialize'

OpenJDK7

$ java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
$ bin/logstash irb
irb(main):001:0> File::Stat.new("/var/tmp/log").dev_minor
=> 51713

jsvd avatar May 06 '15 11:05 jsvd

@mattstibbs can you try installing the package "libc6-dev" (and its dependencies) in your ubuntu instance and check if the issue goes away?

jsvd avatar May 11 '15 08:05 jsvd

@jordansissel is it a viable option to have libc6-dev as a dependency for the deb/rpm packages?

suyograo avatar May 11 '15 15:05 suyograo

@suyograo Yep! I"ll file a bug about it.

jordansissel avatar May 11 '15 18:05 jordansissel

Do we know if this only affects Ubuntu? or Red Hat systems also?

jordansissel avatar May 11 '15 18:05 jordansissel

@jordansissel it affects only ubuntu if using Oracle jdk (not openjdk).

jsvd avatar May 11 '15 19:05 jsvd

For further clarification, this is only known (for now) to reproduce with Ubuntu 14.04 and Oracle Java. OpenJDK's java packages seems unaffected by this bug.

The libc6-dev package requirement had me do some investigation:

Ultimately, this is the fix:

ln -s /lib/x86_64-linux-gnu/libcrypt.so.1 /usr/lib/x86_64-linux-gnu/libcrypt.so


How did I find this? Here's how -

  • Run the reproduction case without the fix:
% strace -fo /tmp/jruby.failing -e trace=file vendor/jruby/bin/jruby -e 'puts File.blockdev?("/")'
NotImplementedError: block device detection unsupported or native support failed to load
  • Now install libc6-dev package
  • Rerun:
% strace -fo /tmp/jruby.working -e trace=file vendor/jruby/bin/jruby -e 'puts File.blockdev?("/")'
false

Now we have two files jruby.failing and jruby.working which only contain file-related syscalls made by any thread (or subprocess) of java. Let's find the unique files:

% awk -F\" '{print $2}' /tmp/jruby.working | sort -u > /tmp/w
% awk -F\" '{print $2}' /tmp/jruby.failing | sort -u > /tmp/f
% diff /tmp/{f,w}
[noise trimmed for clarity]
< /lib/libcrypt.so
< /lib/x86_64-linux-gnu/libcrypt.so
< /usr/lib/libcrypt.so

So, libcrypt, eh?

# Observe the working strace
root@asdf:~/opt/logstash# grep libcrypt /tmp/jruby.working
13764 open("/root/jdk1.8.0_45/bin/../lib/amd64/jli/libcrypt.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
13764 open("/root/jdk1.8.0_45/bin/../lib/amd64/libcrypt.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
13764 open("/lib/x86_64-linux-gnu/libcrypt.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
13764 open("/usr/lib/x86_64-linux-gnu/libcrypt.so", O_RDONLY|O_CLOEXEC) = 12

# observe the failing strace
root@asdf:~/opt/logstash# grep libcrypt /tmp/jruby.failing
11222 open("/root/jdk1.8.0_45/bin/../lib/amd64/jli/libcrypt.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
11222 open("/root/jdk1.8.0_45/bin/../lib/amd64/libcrypt.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
11222 open("/lib/x86_64-linux-gnu/libcrypt.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
11222 open("/usr/lib/x86_64-linux-gnu/libcrypt.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
11222 open("/lib/libcrypt.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
11222 open("/usr/lib/libcrypt.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

libcrypt.so wasn't found! Turns out Ubuntu 14.04's libc6 package doesn't have such a file:

root@asdf:~/opt/logstash# dpkg -L libc6 | grep libcrypt
/lib/x86_64-linux-gnu/libcrypt-2.19.so
/lib/x86_64-linux-gnu/libcrypt.so.1

But the libc6-dev package does:

root@asdf:~/opt/logstash# dpkg -L libc6-dev | grep libcrypt
/usr/lib/x86_64-linux-gnu/libcrypt.a
/usr/lib/x86_64-linux-gnu/libcrypt.so

Because libc6-dev transitively depends on gcc, and some users may not want gcc installed as a dependency of logstash, Ubuntu 14.04 users can patch this by doing this symlink, I think:

ln -s /lib/x86_64-linux-gnu/libcrypt.so.1 /usr/lib/x86_64-linux-gnu/libcrypt.so

jordansissel avatar May 11 '15 22:05 jordansissel

Using CentOS 7, Oracle JDK 1.8.0_45, JRuby 9.0.0.0.pre2, I cannot reproduce. File.blockdev?("/") is OK on this environment.

jordansissel avatar May 11 '15 23:05 jordansissel

@jsvd Sorry for the delay - am on hols in Singapore!

Have just tested after installing libc6-dev and it works fine - as you probably expected!

mattstibbs avatar May 13 '15 06:05 mattstibbs

Encountered this exact error after stepping up from 1.4.2 to 1.5.0 RC4 under Solaris 10.5. Problem was an old JRE; upgraded from Oracle Java 6 to 8 and logs are once again being stashed.

KyleCartmell avatar May 13 '15 19:05 KyleCartmell

I had the same issue on Debian 7.8 Wheezy, but adding the symlink solved the problem. Thanks.

pako-pl avatar May 16 '15 15:05 pako-pl

I am seeing this as well on RHEL6, java 1.7

java -version
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)
./logstash -V
logstash 1.5.0

atman9 avatar Jun 08 '15 19:06 atman9

Hi, I confirm we are having the same issue with: java version "1.7.0_79" OpenJDK Runtime Environment (rhel-2.5.5.3.el6_6-x86_64 u79-b14) OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

CentOS release 6.6 (Final)

logstash-1.5.0

What about this news: http://jruby.org/2015/05/05/jruby-1-7-20.html

Github Issues resolved for 1.7.20:

  • #1754 - JRuby 1.7.11 (bundled with LogStash v. 1.4.1) fails on FreeBSD 10.0 with NotImplementedError: stat.st_dev unsupported or native support failed to load

Could you guys not just use this new JRuby version? greetings

SMMAN avatar Jun 12 '15 05:06 SMMAN