question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Race Condition For First Run

See original GitHub issue

When spawning multiple studies with the same postgres backend, the script crashes because each process tries to create the db table.

Expected behavior

db lock, no crash.

Environment

  • Optuna version: 1.2.0
  • Python version: 3.8

Error messages, stack traces, or logs

..
sqlalchemy.exc.ProgrammingError: ... relation "alembic_version" already exists
..
sqlalchemy.exc.IntegrityError: ... duplicate key value violates unique constraint "pg_type_typename_nsp_index"
..

Steps to reproduce

[delete optuna db tables]
python exp.py exp1 &
python exp.py exp2 &
python exp.py exp3 &

Additional context (optional)

only tried postgres

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
elbarocommented, Apr 6, 2020

Thanks, it solved my problem.

0reactions
jkterry1commented, Dec 1, 2021

@c-bata I’m encountering a similar seeming problem, however I don’t quite follow the solution you proposed and as best I can tell the documentation for it hasn’t been updated either. If you could please explain it in a little more detail I’d be happy to create a PR adding this to the documentation

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a Race Condition? - TechTarget
A race condition is an undesirable situation that occurs when a device or system attempts to perform two or more operations at the...
Read more >
Race conditions and deadlocks - Visual Basic - Microsoft Learn
A race condition occurs when two threads access a shared variable at the same time. The first thread reads the variable, and the...
Read more >
What is a race condition? - Stack Overflow
A race condition occurs when two or more threads can access shared data and they try to change it at the same time....
Read more >
What is a Race Condition? | Baeldung on Computer Science
By definition, a race condition is a condition of a program where its behavior depends on relative timing or interleaving of multiple threads...
Read more >
Race condition - Wikipedia
A race condition can arise in software when a computer program has multiple code paths that are executing at the same time. If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found