New issue 268: FlushError: Instance <UserLog at 0x7f2cecab6f10> has a NULL 
identity key.
https://bitbucket.org/conservancy/kallithea/issues/268/flusherror-instance-has-a-null-identity

Stephan Riedel:

Hi,

I'm currently trying to migrate the kallithea database from from sqlite to 
postgresql via pgloader.

Kallithea version: 0.3.2

```
#!bash

# sqlite3 --version
3.8.7.1 2014-10-29 13:59:56 3b7b72c4685aa5cf5e675c2c47ebec10d9704221
# psql --version
psql (PostgreSQL) 9.4.9
# pgloader --version
pgloader version "3.2.2"
compiled with SBCL 1.3.1.debian
```

When trying to push or pull a repository, I get an HTTP error 500 and the 
following stack trace in the syslog:

```
#!

Feb  7 20:19:39 bsserv24 paster[8288]: 2017-02-07 20:19:39.883 ERROR 
[kallithea.lib.middleware.simplegit] Traceback (most recent call last):
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/kallithea/lib/middleware/simplegit.py",
 line 203, in _handle_request
Feb  7 20:19:39 bsserv24 paster[8288]: self._handle_githooks(repo_name, action, 
baseui, environ)
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/kallithea/lib/middleware/simplegit.py",
 line 296, in _handle_githooks
Feb  7 20:19:39 bsserv24 paster[8288]: log_pull_action(ui=baseui, 
repo=_repo._repo)
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/kallithea/lib/hooks.py", 
line 135, in log_pull_action
Feb  7 20:19:39 bsserv24 paster[8288]: action_logger(user, action, 
ex.repository, ex.ip, commit=True)
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/kallithea/lib/utils.py", 
line 206, in action_logger
Feb  7 20:19:39 bsserv24 paster[8288]: sa.commit()
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 710, in commit
Feb  7 20:19:39 bsserv24 paster[8288]: self.transaction.commit()
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 368, in commit
Feb  7 20:19:39 bsserv24 paster[8288]: self._prepare_impl()
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 347, in _prepare_impl
Feb  7 20:19:39 bsserv24 paster[8288]: self.session.flush()
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 1734, in flush
Feb  7 20:19:39 bsserv24 paster[8288]: self._flush(objects)
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 1809, in _flush
Feb  7 20:19:39 bsserv24 paster[8288]: flush_context.finalize_flush_changes()
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py",
 line 347, in finalize_flush_changes
Feb  7 20:19:39 bsserv24 paster[8288]: 
self.session._register_newly_persistent(state)
Feb  7 20:19:39 bsserv24 paster[8288]: File 
"/srv/kallithea/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 1323, in _register_newly_persistent
Feb  7 20:19:39 bsserv24 paster[8288]: "a load() event." % 
mapperutil.state_str(state)
Feb  7 20:19:39 bsserv24 paster[8288]: FlushError: Instance <UserLog at 
0x7f2cecab6f10> has a NULL identity key.  If this is an auto-generated value, 
check that the database table allows generation of new primary key values, and 
that the mapped Column object is configured to expect these generated values.  
Ensure also that this flush() is not occurring at an inappropriate time, such 
as within a load() event.
```

Google tells me, that this might be connecte to the AUTOINCREMENT feature of 
sqlite but on first sight, all tables/columns using AUTOINCREMENT in sqlite 
were converted correctly to postgres (I think at least).

Can you give me a hint where Kallithea is crashing or which tables might get 
corrupted during conversion?

Also, is there any official guide on how to convert the Kallithea sqlite DB to 
postgres? The grate command (as proposed in the docs) requires some metadata 
for the migration. Where can I find it?


_______________________________________________
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general

Reply via email to