Skip to content

Commit 5909aa6

Browse files
committed
more verbose lock pinging logic
1 parent 4c9f392 commit 5909aa6

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

client/distlock.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ namespace mongo {
5959
return s;
6060
}
6161

62-
void distLockPingThread( ConnectionString addr ) {
62+
void _distLockPingThread( ConnectionString addr ) {
6363
setThreadName( "LockPinger" );
64+
65+
log() << "creating dist lock ping thread for: " << addr << endl;
6466

6567
static int loops = 0;
6668
while( ! inShutdown() ) {
@@ -78,8 +80,8 @@ namespace mongo {
7880
true );
7981
string err = conn->getLastError();
8082
if ( ! err.empty() ) {
81-
log( LL_WARNING ) << "dist_lock process: " << process << " pinging: " << addr << " failed: "
82-
<< err << endl;
83+
warning() << "dist_lock process: " << process << " pinging: " << addr << " failed: "
84+
<< err << endl;
8385
conn.done();
8486
sleepsecs(30);
8587
continue;
@@ -102,8 +104,8 @@ namespace mongo {
102104
conn->remove( lockPingNS , BSON( "_id" << BSON( "$nin" << pids ) << "ping" << LT << fourDays ) );
103105
err = conn->getLastError();
104106
if ( ! err.empty() ) {
105-
log ( LL_WARNING ) << "dist_lock cleanup request from process: " << process << " to: " << addr
106-
<< " failed: " << err << endl;
107+
warning() << "dist_lock cleanup request from process: " << process << " to: " << addr
108+
<< " failed: " << err << endl;
107109
conn.done();
108110
sleepsecs(30);
109111
continue;
@@ -117,14 +119,27 @@ namespace mongo {
117119
conn.done();
118120
}
119121
catch ( std::exception& e ) {
120-
log( LL_WARNING ) << "dist_lock exception during ping: " << e.what() << endl;
122+
warning() << "dist_lock exception during ping: " << e.what() << endl;
121123
}
122124

123-
log(4) << "dist_lock pinged successfully for: " << process << endl;
125+
log( loops % 10 == 0 ? 0 : 1) << "dist_lock pinged successfully for: " << process << endl;
124126
sleepsecs(30);
125127
}
126128
}
127129

130+
void distLockPingThread( ConnectionString addr ) {
131+
try {
132+
_distLockPingThread( addr );
133+
}
134+
catch ( std::exception& e ) {
135+
error() << "unexpected error in distLockPingThread: " << e.what() << endl;
136+
}
137+
catch ( ... ) {
138+
error() << "unexpected unknown error in distLockPingThread" << endl;
139+
}
140+
}
141+
142+
128143
class DistributedLockPinger {
129144
public:
130145
DistributedLockPinger()

0 commit comments

Comments
 (0)