Re: [HACKERS] File descriptor leakage?

From: Cyrus Rahman <cr(at)photox(dot)jcmax(dot)com>
To: Inoue(at)tpf(dot)co(dot)jp, tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] File descriptor leakage?
Date: 1999-08-31 15:12:54
Message-ID: 199908311512.LAA92968@photox.jcmax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I think we ought to hold up 6.5.2 long enough to cram this patch in, but
> I'm hesitant to stick it in the stable branch without some more testing.
> Cyrus, can you try it and see if it fixes your problem?

Ok, I can't actually try the patch for another week or so, since my
development machine has temporarily become a production machine, but thanks to
Hiroshi Inoue's patch I was able to figure out how to demonstrate the problem
in an easily reproducable manner that anyone can test.

As you can see, a connection open through a vacuum does end up duplicating
its open file descriptors. Here's a psql session demonstrating the problem:

cr(at)photox% psql -d template1
Welcome to the POSTGRESQL interactive sql monitor:
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
[PostgreSQL 6.5.1 on i386-unknown-freebsd3.2, compiled by cc ]

type \? for help on slash commands
type \q to quit
type \g or terminate with semicolon to execute query
You are currently connected to the database: template1

template1=> select * from pg_user;
usename|usesysid|usecreatedb|usetrace|usesuper|usecatupd|passwd |valuntil
-------+--------+-----------+--------+--------+---------+--------+----------------------------
pgsql | 70|t |t |t |t |********|Sat Jan 31 01:00:00 2037 EST
cr | 71|t |t |t |t |********|
paxis | 72|f |t |t |t |********|
(3 rows)

template1=>
Suspended

cr(at)photox% ps ax|grep postgres
425 ?? Ss 2:37.25 /usr/local/pgsql/bin/postmaster -i -S -o -F (postgres
90608 ?? S 0:00.06 /usr/local/pgsql/bin/postgres cr localhost template1

cr(at)photox% fstat -p 90608
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W
pgsql postgres 90608 root / 2 drwxr-xr-x 512 r
pgsql postgres 90608 wd /usr 366233 drwx------ 1536 r
pgsql postgres 90608 text /usr 334856 -r-xr-xr-x 1050936 r
pgsql postgres 90608 0 / 967 crw-rw-rw- null rw
pgsql postgres 90608 1 / 967 crw-rw-rw- null rw
pgsql postgres 90608 2 / 967 crw-rw-rw- null rw
pgsql postgres 90608 3 /usr 365266 -rw------- 1712 r
pgsql postgres 90608 4 /usr 366283 -rw------- 262144 rw
pgsql postgres 90608 5* local stream ca3f3b80 <-> ca3f3cc0
pgsql postgres 90608 6 /usr 366236 -rw------- 8192 rw
pgsql postgres 90608 7 /usr 366239 -rw------- 8192 rw
pgsql postgres 90608 8 /usr 366269 -rw------- 16384 rw
pgsql postgres 90608 9 /usr 366238 -rw------- 49152 rw
pgsql postgres 90608 10 /usr 366259 -rw------- 32768 rw
pgsql postgres 90608 11 /usr 366281 -rw------- 8192 rw
pgsql postgres 90608 12 /usr 366235 -rw------- 172032 rw
pgsql postgres 90608 13 /usr 366246 -rw------- 8192 rw
pgsql postgres 90608 14 /usr 366242 -rw------- 8192 rw
pgsql postgres 90608 15 /usr 366249 -rw------- 8192 rw
pgsql postgres 90608 16 /usr 366247 -rw------- 16384 rw
pgsql postgres 90608 17 /usr 366244 -rw------- 65536 rw
pgsql postgres 90608 18 /usr 366262 -rw------- 139264 rw
pgsql postgres 90608 19 /usr 366237 -rw------- 16384 rw
pgsql postgres 90608 20 /usr 366265 -rw------- 16384 rw
pgsql postgres 90608 21 /usr 366261 -rw------- 40960 rw
pgsql postgres 90608 22 /usr 366254 -rw------- 24576 rw
pgsql postgres 90608 23 /usr 366292 -rw------- 0 rw
pgsql postgres 90608 24 /usr 366258 -rw------- 65536 rw
pgsql postgres 90608 25 /usr 366267 -rw------- 16384 rw

cr(at)photox% psql -d template1 -c vacuum
VACUUM

cr(at)photox% !fstat
fstat -p 90608
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W
pgsql postgres 90608 root / 2 drwxr-xr-x 512 r
pgsql postgres 90608 wd /usr 366233 drwx------ 1536 r
pgsql postgres 90608 text /usr 334856 -r-xr-xr-x 1050936 r
pgsql postgres 90608 0 / 967 crw-rw-rw- null rw
pgsql postgres 90608 1 / 967 crw-rw-rw- null rw
pgsql postgres 90608 2 / 967 crw-rw-rw- null rw
pgsql postgres 90608 3 /usr 365266 -rw------- 1712 r
pgsql postgres 90608 4 /usr 366283 -rw------- 262144 rw
pgsql postgres 90608 5* local stream ca3f3b80 <-> ca3f3cc0
pgsql postgres 90608 6 /usr 366236 -rw------- 8192 rw
pgsql postgres 90608 7 /usr 366239 -rw------- 8192 rw
pgsql postgres 90608 8 /usr 366269 -rw------- 16384 rw
pgsql postgres 90608 9 /usr 366238 -rw------- 49152 rw
pgsql postgres 90608 10 /usr 366259 -rw------- 32768 rw
pgsql postgres 90608 11 /usr 366281 -rw------- 8192 rw
pgsql postgres 90608 12 /usr 366235 -rw------- 172032 rw
pgsql postgres 90608 13 /usr 366246 -rw------- 8192 rw
pgsql postgres 90608 14 /usr 366242 -rw------- 8192 rw
pgsql postgres 90608 15 /usr 366249 -rw------- 8192 rw
pgsql postgres 90608 16 /usr 366247 -rw------- 16384 rw
pgsql postgres 90608 17 /usr 366244 -rw------- 65536 rw
pgsql postgres 90608 18 /usr 366262 -rw------- 139264 rw
pgsql postgres 90608 19 /usr 366237 -rw------- 16384 rw
pgsql postgres 90608 20 /usr 366265 -rw------- 16384 rw
pgsql postgres 90608 21 /usr 366261 -rw------- 40960 rw
pgsql postgres 90608 22 /usr 366254 -rw------- 24576 rw
pgsql postgres 90608 23 /usr 366292 -rw------- 0 rw
pgsql postgres 90608 24 /usr 366258 -rw------- 65536 rw
pgsql postgres 90608 25 /usr 366267 -rw------- 16384 rw

cr(at)photox% fg
psql -d template1
select * from pg_user;
usename|usesysid|usecreatedb|usetrace|usesuper|usecatupd|passwd |valuntil
-------+--------+-----------+--------+--------+---------+--------+----------------------------
pgsql | 70|t |t |t |t |********|Sat Jan 31 01:00:00 2037 EST
cr | 71|t |t |t |t |********|
paxis | 72|f |t |t |t |********|
(3 rows)

template1=>
Suspended

cr(at)photox% !fstat
fstat -p 90608
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W
pgsql postgres 90608 root / 2 drwxr-xr-x 512 r
pgsql postgres 90608 wd /usr 366233 drwx------ 1536 r
pgsql postgres 90608 text /usr 334856 -r-xr-xr-x 1050936 r
pgsql postgres 90608 0 / 967 crw-rw-rw- null rw
pgsql postgres 90608 1 / 967 crw-rw-rw- null rw
pgsql postgres 90608 2 / 967 crw-rw-rw- null rw
pgsql postgres 90608 3 /usr 365266 -rw------- 1712 r
pgsql postgres 90608 4 /usr 366283 -rw------- 262144 rw
pgsql postgres 90608 5* local stream ca3f3b80 <-> ca3f3cc0
pgsql postgres 90608 6 /usr 366236 -rw------- 8192 rw
pgsql postgres 90608 7 /usr 366239 -rw------- 8192 rw
pgsql postgres 90608 8 /usr 366269 -rw------- 16384 rw
pgsql postgres 90608 9 /usr 366238 -rw------- 49152 rw
pgsql postgres 90608 10 /usr 366259 -rw------- 32768 rw
pgsql postgres 90608 11 /usr 366281 -rw------- 8192 rw
pgsql postgres 90608 12 /usr 366235 -rw------- 172032 rw
pgsql postgres 90608 13 /usr 366246 -rw------- 8192 rw
pgsql postgres 90608 14 /usr 366242 -rw------- 8192 rw
pgsql postgres 90608 15 /usr 366249 -rw------- 8192 rw
pgsql postgres 90608 16 /usr 366247 -rw------- 16384 rw
pgsql postgres 90608 17 /usr 366244 -rw------- 65536 rw
pgsql postgres 90608 18 /usr 366262 -rw------- 139264 rw
pgsql postgres 90608 19 /usr 366237 -rw------- 16384 rw
pgsql postgres 90608 20 /usr 366265 -rw------- 16384 rw
pgsql postgres 90608 21 /usr 366261 -rw------- 40960 rw
pgsql postgres 90608 22 /usr 366254 -rw------- 24576 rw
pgsql postgres 90608 23 /usr 366292 -rw------- 0 rw
pgsql postgres 90608 24 /usr 366258 -rw------- 65536 rw
pgsql postgres 90608 25 /usr 366267 -rw------- 16384 rw
pgsql postgres 90608 26 /usr 366254 -rw------- 24576 rw
pgsql postgres 90608 27 /usr 366246 -rw------- 8192 rw
pgsql postgres 90608 28 /usr 366242 -rw------- 8192 rw
pgsql postgres 90608 29 /usr 366249 -rw------- 8192 rw
pgsql postgres 90608 30 /usr 366247 -rw------- 16384 rw
pgsql postgres 90608 31 /usr 366244 -rw------- 65536 rw
pgsql postgres 90608 32 /usr 366265 -rw------- 16384 rw
pgsql postgres 90608 33 /usr 366292 -rw------- 0 rw
pgsql postgres 90608 34 /usr 366258 -rw------- 65536 rw
pgsql postgres 90608 35 /usr 366281 -rw------- 8192 rw

cr(at)photox% ls -iR /usr/local/pgsql/data/ | egrep '292|258|281'
366281 pg_shadow
366258 pg_attribute_relid_attnam_index
366292 pg_user

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 1999-08-31 15:22:31 Re: [HACKERS] File descriptor leakage?
Previous Message Massimo Dal Zotto 1999-08-31 15:01:43 bug in array contrib