DBAPI and 'no_magic'

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

DBAPI and 'no_magic'

'no_magic' is an optional parameter for the db 'transaction_begin' for example:
        with DbTxn(_("Gramps XML import"), self.db, batch=True,
                   no_magic=no_magic) as self.trans:

It appears to be a legacy of the bsddb, doesn't show up in any documents on the wiki, and is not listed in the gen.db.base.py.

It was an indicator to the bsddb to allow backlinks to be updated on a commit (when set to True) despite operating in a 'batch' transaction, where backlinks are not normally updated until the end of the transaction.

I found a bug where the GEDCOM importer was not properly fixing up the Sqlite db when the GEDCOM file was not consistent.  Turns out that when the importer tried to 'make_unknown' a family, it was doing a find_backlink_handles still within the batch transaction.  It had previously set no_magic to True, which for bsddb allows the backlinks to be updated as part of the batch transaction.

DBAPI seems to have no code to support the no_magic parameter, and always disables the backlink updates during the batch transaction.

So when make_unknown tried to do the backlink search to find the handles to attach to the family, it came up empty, generating an inconsistent Gramps db.

Nick directed me to post this to developers for any comments.

The question is do we want to support no_magic in dbapi?  Or deprecate the no_magic and fix the code that expects no_magic to do something useful?

Either way we should do something to avoid subtle bugs like this in the future.

Paul C.

Gramps-devel mailing list
[hidden email]