Menu

#49 EXCEPTION: [Errno 9] Bad file descriptor

1.x
closed
2015-02-19
2014-07-24
No

As reported by Michael Day on FreeBSD

2014-07-22 16:19:03,892 barman.cli ERROR: [Errno 9] Bad file descriptor
See log file for more details.

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/barman/cli.py", line 574, in main
    p.dispatch(pre_call=global_config, output_file=_output_stream)
  File "/usr/local/lib/python2.7/site-packages/argh/helpers.py", line 53, in dispatch
    return dispatch(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/argh/dispatching.py", line 125, in dispatch
    for line in lines:
  File "/usr/local/lib/python2.7/site-packages/argh/dispatching.py", line 202, in _execute_command
    for line in result:
  File "/usr/local/lib/python2.7/site-packages/argh/dispatching.py", line 158, in _call
    result = args.function(args)
  File "/usr/local/lib/python2.7/site-packages/barman/cli.py", line 161, in list_backup
    server.list_backups()
  File "/usr/local/lib/python2.7/site-packages/barman/server.py", line 744, in list_backups
    wal_info = self.get_wal_info(backup)
  File "/usr/local/lib/python2.7/site-packages/barman/server.py", line 852, in get_wal_info
    for name, size in self.get_wal_until_next_backup(backup_info):
  File "/usr/local/lib/python2.7/site-packages/barman/server.py", line 836, in get_wal_until_next_backup
    yield (name, size)
  File "/usr/local/lib/python2.7/contextlib.py", line 24, in __exit__
    self.gen.next()
  File "/usr/local/lib/python2.7/site-packages/barman/server.py", line 916, in xlogdb
    f.flush()
IOError: [Errno 9] Bad file descriptor

$ barman diagnose
{
    "global": {
        "config": {
            "barman_home": "/var/lib/barman", 
            "barman_user": "barman", 
            "configuration_files_directory": "/etc/barman.d", 
            "log_file": "/var/log/barman/barman.log", 
            "minimum_redundancy": "2", 
            "retention_policy": "recovery window of 4 weeks"
        }, 
        "system_info": {
            "kernel_ver": "FreeBSD [hostname] 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64", 
            "python_ver": "Python 2.7.8", 
            "release": "", 
            "rsync_ver": "rsync  version 3.1.1  protocol version 31", 
            "ssh_ver": "usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]"
        }
    }, 
    "servers": {
        "main": {
            "backups": {
                "20140719T102233": {
                    "backup_id": "20140719T102233", 
                    "backup_label": "None", 
                    "begin_offset": "5014320", 
                    "begin_time": "Sat Jul 19 10:22:33 2014", 
                    "begin_wal": "00000001000002060000005C", 
                    "begin_xlog": "206/5C4C8330", 
                    "config_file": "/usr/local/pgsql/data/postgresql.conf", 
                    "end_offset": "11081896", 
                    "end_time": "Sat Jul 19 15:01:16 2014", 
                    "end_wal": "0000000100000206000000F7", 
                    "end_xlog": "206/F7A918A8", 
                    "error": null, 
                    "hba_file": "/usr/local/pgsql/data/pg_hba.conf", 
                    "ident_file": "/usr/local/pgsql/data/pg_ident.conf", 
                    "mode": "default", 
                    "pgdata": "/usr/local/pgsql/data", 
                    "server_name": "main", 
                    "size": 71218685801, 
                    "status": "DONE", 
                    "tablespaces": null, 
                    "timeline": 1, 
                    "version": 90103
                }
            }, 
            "config": {
                "active": true, 
                "backup_directory": "/var/lib/barman/main", 
                "backup_options": "exclusive_backup", 
                "bandwidth_limit": null, 
                "barman_home": "/var/lib/barman", 
                "basebackups_directory": "/var/lib/barman/main/base", 
                "compression": null, 
                "conninfo": "host=[hostname] user=[user] dbname=template1", 
                "custom_compression_filter": null, 
                "custom_decompression_filter": null, 
                "description": "main database", 
                "immediate_checkpoint": false, 
                "incoming_wals_directory": "/var/lib/barman/main/incoming", 
                "lock_file": "/var/lib/barman/main/main.lock", 
                "minimum_redundancy": 1, 
                "name": "main", 
                "network_compression": false, 
                "post_backup_script": null, 
                "pre_backup_script": null, 
                "retention_policy": "window 4", 
                "retention_policy_mode": "auto", 
                "ssh_command": "ssh [user]@[hostname]", 
                "tablespace_bandwidth_limit": null, 
                "wal_retention_policy": "simple-wal 4", 
                "wals_directory": "/var/lib/barman/main/wals"
            }, 
            "status": {
                "archive_command": "rsync -a %p [barmanuser]@[hostname]:/var/lib/barman/main/incoming/%f", 
                "archive_mode": "on", 
                "config_file": "/usr/local/pgsql/data/postgresql.conf", 
                "current_xlog": "000000010000020F0000004E", 
                "data_directory": "/usr/local/pgsql/data", 
                "hba_file": "/usr/local/pgsql/data/pg_hba.conf", 
                "ident_file": "/usr/local/pgsql/data/pg_ident.conf", 
                "last_shipped_wal": "000000010000020F0000004D", 
                "pgespresso_installed": false, 
                "server_txt_version": "9.1.3"
            }, 
            "system_info": {
                "kernel_ver": "FreeBSD [hostname] 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64", 
                "python_ver": "python: not found", 
                "release": "", 
                "rsync_ver": "rsync  version 3.0.9  protocol version 30", 
                "ssh_ver": "OpenSSH_5.8p2 FreeBSD-20110503, OpenSSL 0.9.8x 10 May 2012"
            }
        }
    }
}

Discussion

  • Gabriele Bartolini

    • status: open --> accepted
     
  • Giulio Calacoci

    Giulio Calacoci - 2014-08-04

    That exception is raised on BSD systems only, because is not possible to execute a flush on a read only file.

    root@vagrant-freebsd-10:~ # touch /tmp/x
    root@vagrant-freebsd-10:~ # bpython
    
    >>> f=open('/tmp/x','r')
    >>> 
    >>> f.mode
    'r'
    >>> f.flush()
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
    IOError: [Errno 9] Bad file descriptor
    

    On linux no exception is raised

    root@precise64:~ # touch /tmp/x
    root@precise64:~ # bpython
    >>> f= open('/tmp/x','r')
    >>> f.mode
    'r'
    >>> f.flush()
    >>> 
    

    The issue have been fixed in this commit:

    http://sourceforge.net/p/pgbarman/code/ci/ef84c12bcedc9d6b4a1f5062d583d6a01f26cb77

     
  • Giulio Calacoci

    Giulio Calacoci - 2014-08-04
    • status: accepted --> closed
     

Log in to post a comment.