bigpresh / bigpresh/Dancer-Plugin-Database
Applying settings to database() at runtime does not reuse database connections
- Dominant language
- Perl
- Stars
- 39
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
Per documentation, using database() in this way:
```
my $dbh = database({ driver => 'SQLite', database => $filename });
```
causes a brand new connection to be created each time, and old connections don't get disconnected, so the max gets hits quickly.
The problem appears to be in Database.pm, lines 52-54:
```
if (ref $arg eq 'HASH') {
$handle_key = $arg;
$conn_details = _merge_settings($arg, $settings, $logger);
} else {
```
Even though $arg may be the same hash, i.e., { database => "mydb", username="myuser" }, unless special precautions are taken, generating it during runtime creates a different anonymous hashref each time, therefore when used as a key, Perl treats them each as different keys. Since they're different keys, a new connection gets created with each call, and old connections/handles are not reused.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.