From: Richard T. <rjt...@th...> - 2005-12-17 12:47:59
|
On Saturday 17 Dec 2005 01:19, Alex Roitman wrote: > Richard, > > On Fri, 2005-12-16 at 16:36 +0000, Richard Taylor wrote: > > I have been putting together a unittest to build some confidence that the > > reference_map implementation does what it says on the tin. > > > > The unittest is in test/ directory and you can run it with > > RunAllTests.py. > > > > As part of the test I need to populate the db with some records, so I > > have a method that stuffs lots of records into the database. However, > > when I increase the number of records that are inserted I get a strange > > error: > > > > ====================================================================== > > ERROR: test_performance (GrampsDbBase_Test.ReferenceMapTest) > > ---------------------------------------------------------------------- > > Traceback (most recent call last): > > File > > "/home/gramps/devel/Personal/gramps/gramps-HEAD/test/GrampsDbBase_Test.py > >", line 210, in test_performance > > num_links = 10) > > File > > "/home/gramps/devel/Personal/gramps/gramps-HEAD/test/GrampsDbBase_Test.py > >", line 63, in _populate_database > > add_func(lnk_sources) > > File > > "/home/gramps/devel/Personal/gramps/gramps-HEAD/test/GrampsDbBase_Test.py > >", line 115, in _add_event_with_sources > > self._db.commit_event) > > File > > "/home/gramps/devel/Personal/gramps/gramps-HEAD/test/GrampsDbBase_Test.py > >", line 92, in _add_object_with_source > > self._db.transaction_commit(tran, "Add Object") > > File "../src/GrampsBSDDB.py", line 882, in transaction_commit > > GrampsDbBase.transaction_commit(self,transaction,msg) > > File "../src/GrampsDbBase.py", line 1031, in transaction_commit > > self.translist = transaction[0:-1] + [ transaction ] > > AttributeError: Transaction instance has no attribute '__getitem__' > > > > ---------------------------------------------------------------------- > > > > > > You should be able to reproduce this error by increasing the number > > person records inserted into the database to around 100. Look in the > > GrampsDbBase_Test.py file for: > > > > self._populate_database(num_sources = 100, > > num_persons = 10, > > num_families = 10, > > num_events = 10, > > num_places = 10, > > num_media_objects = 10, > > num_links = 10) > > > > Change "num_persons = 10" to "num_persons = 100" and run RunAllTests.py > > again. > > It fails for me with all settings set to 10. My traceback is different, > and is exactly the same as the one I get when I upgrade other objects > (the one I blamed on reference map earlier today :-): > > $ python RunAllTests.py > ====================================================================== > ERROR: check that deleting a primary will remove the backreferences > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/home/shura/devel-gramps/test/GrampsDbBase_Test.py", line 150, > in test_delete_primary > source = self._add_source() > File "/home/shura/devel-gramps/test/GrampsDbBase_Test.py", line 72, in > _add_source > self._db.add_source(source,tran) > File "../src/GrampsDbBase.py", line 743, in add_source > self.commit_source) > File "../src/GrampsDbBase.py", line 713, in _add_object > commit_func(obj,transaction) > File "../src/GrampsDbBase.py", line 382, in commit_source > self._update_reference_map(source,'Source') > File "../src/GrampsBSDDB.py", line 517, in _update_reference_map > ret = primary_cur.set(handle) > File "../src/GrampsBSDDB.py", line 102, in set > return self.cursor.set(str(key)) > DBNotFoundError: (-30989, 'DB_NOTFOUND: No matching key/data pair > found') > > ====================================================================== > ERROR: test_performance (GrampsDbBase_Test.ReferenceMapTest) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/home/shura/devel-gramps/test/GrampsDbBase_Test.py", line 210, > in test_performance > num_links = 10) > File "/home/shura/devel-gramps/test/GrampsDbBase_Test.py", line 42, in > _populate_database > sources.append(self._add_source()) > File "/home/shura/devel-gramps/test/GrampsDbBase_Test.py", line 72, in > _add_source > self._db.add_source(source,tran) > File "../src/GrampsDbBase.py", line 743, in add_source > self.commit_source) > File "../src/GrampsDbBase.py", line 713, in _add_object > commit_func(obj,transaction) > File "../src/GrampsDbBase.py", line 382, in commit_source > self._update_reference_map(source,'Source') > File "../src/GrampsBSDDB.py", line 517, in _update_reference_map > ret = primary_cur.set(handle) > File "../src/GrampsBSDDB.py", line 102, in set > return self.cursor.set(str(key)) > DBNotFoundError: (-30989, 'DB_NOTFOUND: No matching key/data pair > found') > > ====================================================================== > ERROR: Test that the reindex function works. > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/home/shura/devel-gramps/test/GrampsDbBase_Test.py", line 179, > in test_reindex_reference_map > references = [ ref for ref in > self._db.find_backlink_handles(source.get_handle()) ] > File "../src/GrampsBSDDB.py", line 452, in find_backlink_handles > ret = referenced_cur.set(handle) > File "../src/GrampsBSDDB.py", line 102, in set > return self.cursor.set(str(key)) > DBNotFoundError: (-30989, 'DB_NOTFOUND: No matching key/data pair > found') > > ====================================================================== > ERROR: insert a record and a reference and check that > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/home/shura/devel-gramps/test/GrampsDbBase_Test.py", line 138, > in test_simple_lookup > source = self._add_source() > File "/home/shura/devel-gramps/test/GrampsDbBase_Test.py", line 72, in > _add_source > self._db.add_source(source,tran) > File "../src/GrampsDbBase.py", line 743, in add_source > self.commit_source) > File "../src/GrampsDbBase.py", line 713, in _add_object > commit_func(obj,transaction) > File "../src/GrampsDbBase.py", line 382, in commit_source > self._update_reference_map(source,'Source') > File "../src/GrampsBSDDB.py", line 517, in _update_reference_map > ret = primary_cur.set(handle) > File "../src/GrampsBSDDB.py", line 102, in set > return self.cursor.set(str(key)) > DBNotFoundError: (-30989, 'DB_NOTFOUND: No matching key/data pair > found') > > ---------------------------------------------------------------------- > Ran 4 tests in 0.587s > > FAILED (errors=4) > > > > I think it may be different with different libs. > Here's my python and bsddb version info: > > $ python > Python 2.3.5 (#2, Nov 20 2005, 16:40:39) > > >>> import bsddb > >>> bsddb.__version__ > > '4.2.0.5' > I am using 2.4 and 4.3 so it looks like there is a change in behaviour of the cursor.set() method. In 2.4 it returns None if there is no match but in 2.3 it raises an exception. I have put a try: around the call so that it should work in both now, assuming I am not using any other 2.4 only features. I don't have a working 2.3 to try it with, so could you give it a go. This does not solve the other problem that I am seeing though. Richard -- You can normally find me on Jabber as Ric...@ja... |