Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
I've attached a program that opens and closes 100 DB connections with db_postgres. Most of the time it fails for me, the program aborts.
If I use a lock around the open() call to open the DB connection it works every time. However such a lock would be better placed in the db_postgres module to save others from this problem.
The same issue could also apply to db_sqlite and db_mysql.
I wrote this minimal test case because I found that DB queries were sometimes being corrupted in a larger program.
What happened?
I've attached a program that opens and closes 100 DB connections with db_postgres. Most of the time it fails for me, the program aborts.
If I use a lock around the open() call to open the DB connection it works every time. However such a lock would be better placed in the db_postgres module to save others from this problem.
The same issue could also apply to db_sqlite and db_mysql.
I wrote this minimal test case because I found that DB queries were sometimes being corrupted in a larger program.
data_race_db_conn_test.zip
Nim Version
1.6.6
Current Standard Output Logs
Expected Standard Output Logs
Possible Solution
Use a lock in db_postgres' open() proc, and possibly for db_sqlite and db_mysql too.
Additional Information
No response