# Hacking a multi tenancy Prodigy: problem with identical session IDs

**URL:** https://support.prodi.gy/t/hacking-a-multi-tenancy-prodigy-problem-with-identical-session-ids/107
**Category:** Uncategorized
**Tags:** enhancement, database
**Created:** [November 21, 2017, 5:26pm UTC](https://support.prodi.gy/t/hacking-a-multi-tenancy-prodigy-problem-with-identical-session-ids/107 "2017-11-21T17:26:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sundhine](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@sundhine](https://support.prodi.gy/u/sundhine)
#### Post date: [November 21, 2017, 5:26pm UTC](https://support.prodi.gy/t/hacking-a-multi-tenancy-prodigy-problem-with-identical-session-ids/107/1 "2017-11-21T17:26:09Z")

</div>

Hiya,

I am trying to serve multiple users with Prodigy to allow them to annotate subtitles. To this end I have a single Postgres that all the running instances of Prodigy is pointing to.

When I start them up I get the following error:

> peewee.IntegrityError: duplicate key value violates unique constraint "dataset\_name"  
> DETAIL: Key (name)=(2017-11-21\_17-16-29) already exists.

It seems like whenever prodigy starts it tries to enter a minute-unique row in the dataset table and starting a lot of instances up against a single instance causes collisions.

I just wanted to check that for the moment that this is a constraint of Prodigy and we should store things in separate DBs for the moment.

Ta

---

<div class="post-metadata">

### Author: ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)
#### Post date: [November 21, 2017, 5:58pm UTC](https://support.prodi.gy/t/hacking-a-multi-tenancy-prodigy-problem-with-identical-session-ids/107/2 "2017-11-21T17:58:01Z")

</div>

Thanks for the report! This is an interesting constraint we hadn’t considered: When you start a new Prodigy annotation session, a semi-“unique” session ID is generated from the current timestamp. This allows the user and database to distinguish between individual sessions that add to the same dataset.

But it also means that if you start two sessions within the same second, the session IDs will be identical, which causes the error. In theory, this is desired behaviour – but we should probably consider adding an option to let the user plug in their own `get_session_id()` function or simply supply their own, custom session ID.

For now, the simplest workaround would probably be to make sure that you’re always waiting at least one second between starting sessions.

Btw, if you haven’t seen it already, check out [this comment by Matt](https://support.prodi.gy/t/prodigy-annotation-manager-release-date/103/2) on strategies for managing multiple annotators with Prodigy.

---

<div class="post-metadata">

### Author: ![sundhine](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@sundhine](https://support.prodi.gy/u/sundhine)
#### Post date: [November 21, 2017, 6:01pm UTC](https://support.prodi.gy/t/hacking-a-multi-tenancy-prodigy-problem-with-identical-session-ids/107/3 "2017-11-21T18:01:36Z")

</div>

Makes sense. Thanks!
