-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat: Track dirty table writes and long transactions #42345
Conversation
3969ff2
to
08c3a4d
Compare
a20123e
to
b0124cd
Compare
f3f48a4
to
305f9dd
Compare
305f9dd
to
da4600a
Compare
if ($this->getTransactionNestingLevel() === 0) { | ||
$timeTook = microtime(true) - $this->transactionActiveSince; | ||
$this->transactionActiveSince = null; | ||
if ($timeTook > 1) { |
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.
this will be true very often. should we use a lower threshold like 10ms?
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.
microtime will actually return seconds if true is passed on as a parameter so a float is returned. So this would only log if greater 1 second
da4600a
to
d1d2794
Compare
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.
Nice
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.
typo :)
d1d2794
to
3fecfef
Compare
3fecfef
to
139c022
Compare
Signed-off-by: Julius Härtl <[email protected]>
…k to replicas if reads go to other tables Signed-off-by: Julius Härtl <[email protected]> debug: error log Signed-off-by: Julius Härtl <[email protected]>
139c022
to
c17c42a
Compare
Summary
The main benefit of this approach is that we can switch back to read replicas for queries that are not towards dirty tables (that were written before), which makes #41998 more performant as less reads go to the primary. In addition the logging can be used to more easily track down read after write by using the debug log.
In addition logging long transactions can be a good indicator for code paths that might need rework to avoid long locks or could cause potential deadlock scenarios.