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
Support Questions
status variable
#2422
Conversation
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.
Awesome job with the tests for this one.
I just had a couple minor suggestions, and wanted to clarify the double incrementing you saw on errors. I wasn't able to reproduce that in a quick test with MySQL, but I might be missing something.
// for some reason, errors count as two questions | ||
incVal = int64(2) | ||
} | ||
// ignore all errors relating to status updates |
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.
Good note about ignoring errors. That seems appropriate here. It might be helpful to add a similar comment mentioning that there is a race condition here, but we are consciously making the tradeoff to have a small risk of race condition and losing a question count or two instead of taking on the extra expense of a mutex. Alternatively... I saw your comment below about considering spinning up a go routine. If we do want to add locking here, then I think you're right it would make sense to spin up a goroutine at that point.
I mention that, since I think someone looking at this code in the future might wonder why there is no locking, so it's nice to encode that decision in a comment.
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.
Btw... any more context on how you saw the count being incremented twice for errors? I'm not seeing the same behavior. I do see an increment of 2, but I think one is for the error statement and one is for SHOW STATUS
:
mysql> show status like 'Questions';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Questions | 19 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show status like 'Questions';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Questions | 20 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> asdf;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'asdf' at line 1
mysql> show status like 'Questions';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Questions | 22 |
+---------------+-------+
1 row in set (0.00 sec)
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 is what I see from MySQL:
mysql> show status like "questions";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Questions | 41 |
+---------------+-------+
1 row in set (0.0010 sec)
mysql> asdf;
ERROR: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'asdf' at line 1
mysql> show status like "questions";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Questions | 44 |
+---------------+-------+
1 row in set (0.0012 sec)
I think it might be running a query under the hood to log errors? or... it's some windows quirk.
I'll just have it increment by one now, and can just update it whenever I figure out why errors are counted twice on my machine.
This PR adds logic to update status variable
Questions
.This only works in the server context, probably doesn't through
dolt sql
cli.dolthub/dolt#7646