Duplicate entry for key

Hi there,

Vikunja API sometimes has the following errors (logged in standard.log):
2021-02-22T17:13:32.443254822+01:00: ERROR :arrow_forward: handler/CreateWeb 10a Error 1062: Duplicate entry ‘25’ for key ‘tasks.PRIMARY’
2021-02-22T17:13:37.678825354+01:00: ERROR :arrow_forward: handler/CreateWeb 13b Error 1062: Duplicate entry ‘26’ for key ‘tasks.PRIMARY’
2021-02-22T17:28:27.449597143+01:00: ERROR :arrow_forward: handler/CreateWeb 1db Error 1062: Duplicate entry ‘27’ for key ‘tasks.PRIMARY’
2021-02-22T17:28:28.251333664+01:00: ERROR :arrow_forward: handler/CreateWeb 1ec Error 1062: Duplicate entry ‘28’ for key ‘tasks.PRIMARY’
2021-02-22T17:28:28.913073506+01:00: ERROR :arrow_forward: handler/CreateWeb 1fd Error 1062: Duplicate entry ‘29’ for key ‘tasks.PRIMARY’
2021-02-22T17:28:29.399452714+01:00: ERROR :arrow_forward: handler/CreateWeb 20e Error 1062: Duplicate entry ‘30’ for key ‘tasks.PRIMARY’
2021-02-22T17:28:29.949177294+01:00: ERROR :arrow_forward: handler/CreateWeb 21f Error 1062: Duplicate entry ‘31’ for key ‘tasks.PRIMARY’
2021-02-22T17:28:30.454744812+01:00: ERROR :arrow_forward: handler/CreateWeb 230 Error 1062: Duplicate entry ‘32’ for key ‘tasks.PRIMARY’
2021-02-22T17:28:45.241768395+01:00: ERROR :arrow_forward: handler/CreateWeb 255 Error 1062: Duplicate entry ‘34’ for key ‘tasks.PRIMARY’
2021-02-22T17:28:46.289698421+01:00: ERROR :arrow_forward: handler/CreateWeb 266 Error 1062: Duplicate entry ‘35’ for key ‘tasks.PRIMARY’
2021-02-22T17:28:47.026374293+01:00: ERROR :arrow_forward: handler/CreateWeb 277 Error 1062: Duplicate entry ‘36’ for key ‘tasks.PRIMARY’

The user is unable to add new tasks, instead an exception error 500 is displayed. Everything else seems to work fine. After trying to add the task about 100 times it worked, as there was no “duplicate entry” anymore.
I had upgraded vikunja to version v0.16.0 some days ago. I’m running mysql version 8.0.20 on debian 10.

I could imagine the error is based on a bug, where vikunja wants to use primary keys, despite they are already in use for exisiting tasks.

Has anybody had a similar problem?

Regards,
Gian

That sounds like the primary key count got messed up or reset, but I think that’s a MySQL issue and not necessarily something Vikunja could fix.

Little update on this issue after a while:
There is an error in the primary key auto incremental. After every upgrade of vikunja api the counters are somehow reset to zero. Let’s say a user already had 100 Tasks before the upgrade, then the user cannot create a new task 100 times. After that it works just fine.

I could not find anything wrong in the database or with mysql. I’ll try to setup a fresh database, hopefully that helps.