removeFile crashes because random.choice is trying to index a set

Bug #57237 reported by Christian Reis
2
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Malcolm Cleaton

Bug Description

The DiskPool.removeFile() method crashes occasionally because random.choice is trying to index a set. This happens when we try to remove a real file (not a symlink) and there are symlinks to it.

           targetcomponent = random.choice(pool_entry.comps)

You can't do random.choice on pool_entry.comps, because it's a set. This needs:

  a) a test
  b) to drop random.choice, replacing it with a comment explaining we just use any arbitrary component, and list(pool_entry.comps)[0].

You can't index sets. There don't seem to be any other cases in that file which do that.

http://librarian.launchpad.net/3971730/w5qEocb2un4qQdItymLF8vCh4mu.txt
http://librarian.launchpad.net/3973608/ahZUWCVSgEGdCMZAcFdw5zDhpzk.txt

Tags: lp-soyuz
Christian Reis (kiko)
Changed in soyuz:
assignee: nobody → malcolmcleaton
importance: Untriaged → High
status: Unconfirmed → Confirmed
Revision history for this message
Andrew Bennetts (spiv) wrote :

Nitpicks: pool_entry.comps appears to be a dict, not a set. Either way "iter(pool_entry.comps).next()" is slightly nicer way to pick an arbitrary element non-destructively, because it doesn't copy the entire collection.

Revision history for this message
Malcolm Cleaton (malcolmcleaton) wrote :

pool_entry.comps is totally a set.

I agree your code is nicer though, and I'll use it.

Revision history for this message
Malcolm Cleaton (malcolmcleaton) wrote :

r3958

Changed in soyuz:
status: Confirmed → Fix Committed
Celso Providelo (cprov)
Changed in soyuz:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.