-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CA-407313: Replace semaphore & spinlock with rwlock #26
Conversation
rwlock decreases the amount of blocking for logging by separating the locking for logging to thread safe stdio versus thread unsafe operations such as reopening files. Use flockfile/funlockfile to ensure contiguous log messages where needed. Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
don't hold the rwlock during syslogging (except for the wrlock during reopen) release the lock before syslogging Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
pthread_spin_destroy(&lock); | ||
#endif | ||
pthread_rwlock_unlock(&lock); | ||
pthread_rwlock_destroy(&lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked the order of cleanup/termination, but destroying the lock can be problematic if other threads try to use it afterwards. I realized that the previous code did this too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll investigate the clean up order to determine if this can safely be destroyed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log_terminate
is used once when the threads haven't been setup yet (e.g. if a license check fails), and again after the clean up once each of the threads have been terminated
Therefore destroying the lock during log_terminate
is safe
Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
// | ||
|
||
va_start(ap, fmt); | ||
vfprintf(fpLogfile, fmt, ap); |
Check warning
Code scanning / CodeChecker
the value returned by this function should not be disregarded; neglecting it may lead to errors Warning
// | ||
|
||
va_start(ap, fmt); | ||
vfprintf(fpLogfile, fmt, ap); |
Check warning
Code scanning / CodeChecker
format string is not a string literal Warning
|
||
for (; col < MAX_COL; col++) | ||
{ | ||
fprintf(fpLogfile, " "); |
Check warning
Code scanning / CodeChecker
the value returned by this function should not be disregarded; neglecting it may lead to errors Warning
fprintf(fpLogfile, " "); | ||
} | ||
|
||
fprintf(fpLogfile, ": %s\n", asc_dmp); |
Check warning
Code scanning / CodeChecker
the value returned by this function should not be disregarded; neglecting it may lead to errors Warning
rwlock decreases the amount of blocking for logging by separating the
locking for logging to thread safe stdio versus thread unsafe
operations such as reopening files.
Use flockfile/funlockfile to ensure contiguous log messages where
needed.
Signed-off-by: Gerald Elder-Vass gerald.elder-vass@cloud.com
Tested on a pool which previously had HA enabled; disabled HA, updated xha, re-enabled HA and monitored the pool for a while (and some operations to spark some logging)