feat: Track dirty table writes and long transactions - #42345
Merged
Conversation
juliusknorr
force-pushed
the
enh/read-replica-followup
branch
2 times, most recently
from
December 18, 2023 09:40
3969ff2 to
08c3a4d
Compare
5 tasks
juliusknorr
force-pushed
the
enh/read-replica-followup
branch
3 times, most recently
from
December 18, 2023 19:14
a20123e to
b0124cd
Compare
juliusknorr
marked this pull request as ready for review
December 28, 2023 07:21
juliusknorr
force-pushed
the
enh/read-replica-followup
branch
2 times, most recently
from
December 28, 2023 07:28
f3f48a4 to
305f9dd
Compare
juliusknorr
requested review from
a team,
Altahrim,
ArtificialOwl,
icewind1991 and
kesselb
and removed request for
a team
December 28, 2023 07:31
juliusknorr
force-pushed
the
enh/read-replica-followup
branch
from
December 28, 2023 11:50
305f9dd to
da4600a
Compare
| if ($this->getTransactionNestingLevel() === 0) { | ||
| $timeTook = microtime(true) - $this->transactionActiveSince; | ||
| $this->transactionActiveSince = null; | ||
| if ($timeTook > 1) { |
Member
There was a problem hiding this comment.
this will be true very often. should we use a lower threshold like 10ms?
Member
Author
There was a problem hiding this comment.
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
juliusknorr
force-pushed
the
enh/read-replica-followup
branch
from
December 29, 2023 10:17
da4600a to
d1d2794
Compare
juliusknorr
force-pushed
the
enh/read-replica-followup
branch
from
January 3, 2024 22:31
d1d2794 to
3fecfef
Compare
ChristophWurst
approved these changes
Jan 8, 2024
Altahrim
approved these changes
Jan 10, 2024
juliusknorr
force-pushed
the
enh/read-replica-followup
branch
from
January 11, 2024 11:54
3fecfef to
139c022
Compare
Signed-off-by: Julius Härtl <jus@bitgrid.net>
…k to replicas if reads go to other tables Signed-off-by: Julius Härtl <jus@bitgrid.net> debug: error log Signed-off-by: Julius Härtl <jus@bitgrid.net>
juliusknorr
force-pushed
the
enh/read-replica-followup
branch
from
January 12, 2024 10:02
139c022 to
c17c42a
Compare
This was referenced Jan 17, 2024
This was referenced Jan 29, 2024
8 tasks
Merged
8 tasks
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.