Bug 112818 - ports-mgmt/portupgrade -a fails with database error
Summary: ports-mgmt/portupgrade -a fails with database error
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Chris Rees
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-20 20:50 UTC by gerald
Modified: 2012-04-16 18:33 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gerald 2007-05-20 20:50:03 UTC
	I have a hunch that 
	  [database version mismatch/bump detected] Permission denied
	might be the important hint here, but even removing the
	/var/db/pkg/pkgdb.db files does not make any difference.

	And removing /var/db/pkg/pkgdb.db and then directly invoking
	portupgrade -a runs into exactly the same issue.

sputnik1# cd /var/db/pkg/
sputnik1# rm pkgdb.db
sputnik1# pkgdb -F
--->  Checking the package registry database
[Rebuilding the pkgdb <format:bdb_btree> in /var/db/pkg ... - 57 packages found (-0 +57) ......................................................... done]
sputnik1# portupgrade -a
[database version mismatch/bump detected] Permission denied
/usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:493:in `open_db': database file error (PortsDB::DBError)
        from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:647:in `port'
        from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:835:in `all_depends_list'
        from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:825:in `tsort_build'
        from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:817:in `each'
        from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:817:in `tsort_build'
        from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:839:in `sort_build'
        from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:843:in `sort_build!'
        from /usr/local/sbin/portupgrade:738:in `main'
        from /usr/local/lib/ruby/1.8/optparse.rb:755:in `initialize'
        from /usr/local/sbin/portupgrade:221:in `new'
        from /usr/local/sbin/portupgrade:221:in `main'
        from /usr/local/sbin/portupgrade:2172
/usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:493: [BUG] Segmentation fault
ruby 1.8.5 (2006-08-25) [i386-freebsd6]

Abort (core dumped)

sputnik1# gdb /usr/local/bin/ruby18 ruby18.core

...bt...

#0  0x48243ecb in kill () from /lib/libc.so.6
[New LWP 100047]
(gdb) bt
#0  0x48243ecb in kill () from /lib/libc.so.6
#1  0x48169236 in raise () from /lib/libpthread.so.2
#2  0x48242b78 in abort () from /lib/libc.so.6
#3  0x4809638d in rb_bug () from /usr/local/lib/libruby18.so.18
#4  0x480f81df in sigsegv () from /usr/local/lib/libruby18.so.18
#5  0x4816ff5d in sigaction () from /lib/libpthread.so.2
#6  0xbfbfff94 in ?? ()
#7  0x0000000b in ?? ()
#8  0xbfbfe750 in ?? ()
#9  0xbfbfe490 in ?? ()
#10 0x00000000 in ?? ()
#11 0x4816fa24 in sigaction () from /lib/libpthread.so.2
#12 0x48287dd0 in i_close ()
   from /usr/local/lib/ruby/site_ruby/1.8/i386-freebsd6/bdb.so
#13 0x48098c09 in rb_protect () from /usr/local/lib/libruby18.so.18
#14 0x48287e90 in bdb_free ()
   from /usr/local/lib/ruby/site_ruby/1.8/i386-freebsd6/bdb.so
#15 0x480b55fe in rb_gc_call_finalizer_at_exit ()
   from /usr/local/lib/libruby18.so.18
#16 0x48098b19 in ruby_finalize_1 () from /usr/local/lib/libruby18.so.18
#17 0x480ab350 in ruby_cleanup () from /usr/local/lib/libruby18.so.18
#18 0x480ab417 in ruby_stop () from /usr/local/lib/libruby18.so.18
#19 0x480ab46e in ruby_run () from /usr/local/lib/libruby18.so.18
#20 0x08048607 in main ()
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2007-05-20 22:30:18 UTC
Responsible Changed
From-To: freebsd-ports-bugs->sem

Over to maintainer
Comment 2 Sergey Matveychuk freebsd_committer freebsd_triage 2007-06-15 07:27:22 UTC
What about /usr/ports/INDEX.db file? Remove it too.

-- 
Dixi.
Sem.
Comment 3 Sergey Matveychuk freebsd_committer freebsd_triage 2007-06-15 11:10:20 UTC
State Changed
From-To: open->feedback

Ask submitter for an action
Comment 4 Sergey Matveychuk freebsd_committer freebsd_triage 2007-08-09 15:18:23 UTC
State Changed
From-To: feedback->closed

Not a portupgrade bug
Comment 5 Gerald Pfeifer freebsd_committer freebsd_triage 2007-09-16 23:56:16 UTC
State Changed
From-To: closed->open

The current version of portupgrade-devel (2.3.1) behaves differently: 

sputnik1# portupgrade -a 
cd: can't cd to /usr/ports 
cd: can't cd to /usr/ports/ports-mgmt/portupgrade 
cd: can't cd to /usr/ports 
Fetching the ports index ... index file directory /usr/ports not writable! 
index generation error 
/usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:493:in `open_db': database file error (PortsDB::DBError) 
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:647:in `port' 
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:835:in `all_depends_list' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:825:in `tsort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:817:in `each' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:817:in `tsort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:839:in `sort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:843:in `sort_build!' 
from /usr/local/sbin/portupgrade:741:in `main' 
from /usr/local/lib/ruby/1.8/optparse.rb:755:in `initialize' 
from /usr/local/sbin/portupgrade:221:in `new' 
from /usr/local/sbin/portupgrade:221:in `main' 
from /usr/local/sbin/portupgrade:2175 

Ah, I should set PORTSDIR since this is a non-default setup. 

sputnik1# setenv PORTSDIR /sw/test/FreeBSD/ports/ 
sputnik1# portupgrade -a 

Fetching the ports index ... index file directory /sw/test/FreeBSD/ports not writable! 
index generation error 
/usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:493:in `open_db': database file error (PortsDB::DBError) 
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:647:in `port' 
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:835:in `all_depends_list' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:825:in `tsort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:817:in `each' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:817:in `tsort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:839:in `sort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:843:in `sort_build!' 
from /usr/local/sbin/portupgrade:741:in `main' 
from /usr/local/lib/ruby/1.8/optparse.rb:755:in `initialize' 
from /usr/local/sbin/portupgrade:221:in `new' 
from /usr/local/sbin/portupgrade:221:in `main' 
from /usr/local/sbin/portupgrade:2175 

Okay, so use the (undocumented) INDEXDIR setting. 

sputnik1# setenv INDEXDIR /var/tmp 
sputnik1# portupgrade -a 
Fetching the ports index ... index file directory /sw/test/FreeBSD/ports not writable! 
index generation error 

Hmm, portupgrade ignores INDEXDIR, it seems! 

So, I believe there are two bugs here: 

1. portupgrade ignores INDEXDIR, always going into $PORTSDIR. 

2. portupgrade should not issue a full ruby backtrace when it's not able 
to read the database (the INDEX, I assume) but exit after the error 
message "index generation error".
Comment 6 rsecor 2007-10-04 15:17:41 UTC
Out of curiosity...

 > cd: can't cd to /usr/ports
 > cd: can't cd to /usr/ports/ports-mgmt/portupgrade
 > cd: can't cd to /usr/ports
 > Fetching the ports index ... index file directory /usr/ports not  
writable!

Are you running as root or suing to root first?
does /usr/ports exist?
who owns /usr/ports?
did you download the ports.tgz file and uncompress it until /usr/ports?

Rich
Comment 7 Sergey Matveychuk freebsd_committer freebsd_triage 2007-12-25 12:05:35 UTC
 > 2. portupgrade should not issue a full ruby backtrace when it's not able
 > to read the database (the INDEX, I assume) but exit after the error
 > message "index generation error".

If you'll take a look inside portupgrade code you see no backtrace 
prints. It's a ruby issue. If you know how to shut up ruby, tell us.

-- 
Dixi.
Sem.
Comment 8 Sergey Matveychuk freebsd_committer freebsd_triage 2008-07-01 00:11:17 UTC
State Changed
From-To: open->feedback

Confirm please if the bug still exists?
Comment 9 Gerald Pfeifer freebsd_committer freebsd_triage 2008-07-06 20:42:46 UTC
State Changed
From-To: feedback->open

Yes, I can still reproduce this, just a bit differently: 

sputnik1# pkgdb -F 
--->  Checking the package registry database 
sputnik1# portupgrade -a 
Fetching the ports index ... index file directory /sw/test/FreeBSD/ports not writable! 
index generation error 
/usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:493:in `open_db': database file error (PortsDB::DBError) 
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:647:in `port' 
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:835:in `all_depends_list' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:825:in `tsort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:817:in `each' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:817:in `tsort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:839:in `sort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:843:in `sort_build!' 
from /usr/local/sbin/portupgrade:786:in `main' 
from /usr/local/lib/ruby/1.8/optparse.rb:755:in `initialize' 
from /usr/local/sbin/portupgrade:229:in `new' 
from /usr/local/sbin/portupgrade:229:in `main' 
from /usr/local/sbin/portupgrade:2173
Comment 10 Sergey Matveychuk freebsd_committer freebsd_triage 2008-07-18 14:49:24 UTC
State Changed
From-To: open->feedback

Ask for an additional info
Comment 11 gerald 2008-08-10 23:35:07 UTC
On Fri, 18 Jul 2008, Sergey Matveychuk wrote:
> What about permissions for the directories?

Sorry about the delay in getting back to this -- I've been travelling
and access to my remote tester where I have been seeing this was flaky.

You are right: root could not write into $PORTSDIR even though it looked
as it should, but NFS root squashing hit even though the directory had
group wheel and was group-writeable.  Making $PORTSDIR world writable
addressed this.

So I guess this mainly leaves the question how we can improve the failure
mode here?

Thanks for your patience!

Gerald
Comment 12 gerald 2008-08-11 00:11:44 UTC
On Mon, 11 Aug 2008, Gerald Pfeifer wrote:
> So I guess this mainly leaves the question how we can improve the failure
> mode here?

I've thought a bit about this; how about something like the following
if $PORTSDIR is not writeable?

  Cannot write INDEX into $PORTSDIR; set PORTS_INDEX to save the
  index at an alternate location.

And similarily for distfiles:

  Cannot save into $DISTDIR; set DISTDIR to a writeable location
  to proceed.


With these two changes, I now have an apparently successful portupgrade
run, for the first time with a centralized (NFS mounted) ports tree that
is not writeable for root. :-)

portupgrade works like a charm in such a setting, it's really only a bit
of usability that may deter users.  Great work!

Gerald
Comment 13 Sergey Matveychuk freebsd_committer freebsd_triage 2008-08-12 16:26:25 UTC
State Changed
From-To: feedback->closed

Positive feedback. Thanks.
Comment 14 Gerald Pfeifer freebsd_committer freebsd_triage 2009-01-31 00:37:24 UTC
State Changed
From-To: closed->open

Umm, I'm afraid not.  This really is about error handling and the 
current failure mode, and I ran into it today: 

sputnik1# portupgrade -a 
Fetching the ports index ... index file directory /sw/test/FreeBSD/ports not writable! 
index generation error 
/usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:493:in `open_db': database file error (PortsDB::DBError) 
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:661:in `port' 
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:849:in `all_depends_list' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:843:in `tsort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:835:in `each' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:835:in `tsort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:857:in `sort_build' 
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:861:in `sort_build!' 
from /usr/local/sbin/portupgrade:791:in `main' 
from /usr/local/lib/ruby/1.8/optparse.rb:785:in `initialize' 
from /usr/local/sbin/portupgrade:229:in `new' 
from /usr/local/sbin/portupgrade:229:in `main' 
from /usr/local/sbin/portupgrade:2208 

See my 11 Aug 2008 comment on how I suggest to handle this instead, 
to give more guidance to the user.  And avoid those 10+ lines of a 
Ruby backrace.
Comment 15 Sergey Matveychuk freebsd_committer freebsd_triage 2009-01-31 12:10:39 UTC
Note: Fetching the ports index ... index file directory 
/sw/test/FreeBSD/ports not writable!

Have you tried to set INDEXDIR to another place?

-- 
Dixi.
Sem.
Comment 16 gerald 2009-02-01 14:23:34 UTC
On Sat, 31 Jan 2009, Sergey Matveychuk wrote:
> Have you tried to set INDEXDIR to another place?

Yes, that works.  Here is what I suggest to address the PR:

1. Change "Fetching the ports index ... index file directory 
   /sw/test/FreeBSD/ports not writable!"

     to

   "Fetching the ports index ... directory /sw/test/FreeBSD/ports not 
   writable; consider setting INDEXDIR."

2. Abort portupgrade at that point, instead of running into problems
   later on and issuing a Ruby backtrace.

Gerald
Comment 17 gerald 2009-02-01 14:26:29 UTC
Sorry, I was wrong:  My Sun Sep 16 22:56:16 UTC 2007 comment still
applies, and there are in fact three issues here:

3. portupgrade ignores INDEXDIR.
Comment 18 Mark Linimon freebsd_committer freebsd_triage 2009-07-25 02:47:56 UTC
Responsible Changed
From-To: sem->ruby

sem@ has turned over maintainership of portupgrade to the ruby mailing list.
Comment 19 Philip M. Gollucci freebsd_committer freebsd_triage 2010-09-10 00:10:12 UTC
Responsible Changed
From-To: ruby->pgollucci

I will take it
Comment 20 Philip M. Gollucci freebsd_committer freebsd_triage 2010-09-24 07:21:24 UTC
Responsible Changed
From-To: pgollucci->freebsd-ports-bugs

going to have enotime for the next 2 weeks, sorry
Comment 21 Steve Price freebsd_committer freebsd_triage 2011-01-03 17:22:38 UTC
Responsible Changed
From-To: freebsd-ports-bugs->ruby

Over to maintainer(s).
Comment 22 Philip M. Gollucci freebsd_committer freebsd_triage 2012-02-22 05:22:36 UTC
State Changed
From-To: open->suspended

Over to maintainer. 


Comment 23 Philip M. Gollucci freebsd_committer freebsd_triage 2012-02-22 05:22:36 UTC
Responsible Changed
From-To: ruby->freebsd-ports-bugs

Over to maintainer.
Comment 24 Chris Rees freebsd_committer freebsd_triage 2012-04-12 11:03:08 UTC
State Changed
From-To: suspended->open

This should not be suspended.
Comment 25 Bryan Drewery 2012-04-16 03:42:40 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This has been fixed in the upstream. INDEXDIR is now respected. It is
now available in the latest portupgrade-devel port and will be included
in the next release.

Thanks,
Bryan Drewery

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPi4cfAAoJEG54KsA8mwz51vUP/3JJsI75oWr4NaS8TYZ/46ZS
tHAFSkEfjaQ2BMqD17zyxrMmoj1v31Pq/d5rIN//sfceDGyyCszYiGkxGzddPy0M
VLGeFyJ25Y8UqBpFw0a+xJGD9JA2ITazXcYNcaViBpSBtSYXcPwZy30PulOLvTg3
R1rm1rljhUqpzmgVmsKZS0gMBLKzPcpLKkoaZRmxAIvDmc1oozyB9UskYL9pyHaT
QNHuWjN1SPS07vEjP3x2GbXcKoRoDIIsmy4p+9y91OrWqq2RB4k1gOXqRz7zdd5Z
9gzeQOJ04ZdyfvtCQyLyTN6o6wyDAvxHCBm02pIEW5zdnrZW/aEa18AcTEeDlmFy
ZIcST/ptCJ3jiAPe9ZQp0hLun0HVfuq6ljzRtKI7mZ2PtWuivUTGQm2oDv4w0hoD
GLUPzJE3k308wWETxID5OThHr//nvnTJVvKX2VMxFn9fGSGKqhQsGEa92ENUiS5z
rmvuUNahSyvjZyGoaR5fuH+xsQabozFVdWiS9cp19PH0/ymlhQF8grBTmLIWRMJd
A8UoJ0tfkjbqKUJmIH/P4X17eWp8KbVxCJxFUy8jY0QOfgIRaFPPKqeUTbREw+a0
OBVs+mFaABYjZ+4Nbj/uHoBzBkHi40Ufp/DA40y/VbVWNtjIq87v//85DwhDqY11
RV0j4AnjyNoA7LeHKVIY
=0L45
-----END PGP SIGNATURE-----
Comment 26 Chris Rees freebsd_committer freebsd_triage 2012-04-16 18:32:48 UTC
State Changed
From-To: open->closed

Fixed in upstream.
Comment 27 Chris Rees freebsd_committer freebsd_triage 2012-04-16 18:33:12 UTC
Responsible Changed
From-To: freebsd-ports-bugs->crees

Take responsibility