36{
38
39 _open.push([
this, name, updatesEnabledForThis, &pool]() ->
bool
40 {
41 std::string
const dbString =
sConfigMgr->GetOption<std::string>(name +
"DatabaseInfo",
"");
42 if (dbString.empty())
43 {
45 "\nSearch the wiki for ACE00047 in Common Errors (https://www.azerothcore.org/wiki/common-errors#ace00043)", name);
46 return false;
47 }
48
50 if (asyncThreads < 1 || asyncThreads > 32)
51 {
52 LOG_ERROR(
_logger,
"{} database: invalid number of worker threads specified. "
53 "Please pick a value between 1 and 32.", name);
54 return false;
55 }
56
58
60
62 {
63
64 if (error == CR_CONNECTION_ERROR)
65 {
68 uint8 reconnectCount = 0;
69
70 while (reconnectCount < attempts)
71 {
73 std::this_thread::sleep_for(reconnectSeconds);
75
76 if (error == CR_CONNECTION_ERROR)
77 {
78 reconnectCount++;
79 }
80 else
81 {
82 break;
83 }
84 }
85 }
86
87
88 if ((error == ER_BAD_DB_ERROR) && updatesEnabledForThis &&
_autoSetup)
89 {
90
92 {
93 error = 0;
94 }
95 }
96
97
98 if (error)
99 {
100 LOG_ERROR(
_logger,
"DatabasePool {} NOT opened. There were errors opening the MySQL connections. "
101 "Check your log file for specific errors", name);
102
103 return false;
104 }
105 }
106
108 {
110 });
111
112 return true;
113 });
114
115
116 if (updatesEnabledForThis)
117 {
118 _populate.push([
this, name, &pool]() ->
bool
119 {
121 {
122 LOG_ERROR(
_logger,
"Could not populate the {} database, see log for details.", name);
123 return false;
124 }
125
126 return true;
127 });
128
129 _update.push([
this, name, &pool]() ->
bool
130 {
132 {
133 LOG_ERROR(
_logger,
"Could not update the {} database, see log for details.", name);
134 return false;
135 }
136
137 return true;
138 });
139 }
140
141 _prepare.push([
this, name, &pool]() ->
bool
142 {
144 {
145 LOG_ERROR(
_logger,
"Could not prepare statements of the {} database, see log for details.", name);
146 return false;
147 }
148
149 return true;
150 });
151
152 return *this;
153}
std::uint8_t uint8
Definition: Define.h:110
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
#define LOG_WARN(filterType__,...)
Definition: Log.h:163
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:30
bool PrepareStatements()
Prepares all prepared statements.
Definition: DatabaseWorkerPool.cpp:146
uint32 Open()
Definition: DatabaseWorkerPool.cpp:100
void SetConnectionInfo(std::string_view infoString, uint8 const asyncThreads, uint8 const synchThreads)
Definition: DatabaseWorkerPool.cpp:91
void Close()
Definition: DatabaseWorkerPool.cpp:126
std::queue< Predicate > _populate
Definition: DatabaseLoader.h:80
std::queue< Predicate > _prepare
Definition: DatabaseLoader.h:80
std::queue< Predicate > _update
Definition: DatabaseLoader.h:80
std::queue< Predicate > _open
Definition: DatabaseLoader.h:80
std::stack< Closer > _close
Definition: DatabaseLoader.h:81
Definition: DBUpdater.h:68
static bool IsEnabled(uint32 const updateMask)