-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Update to fix CONSTRAINT_4 error for spawnpoint table #2416
Conversation
I wanted to try this, I am using MariaDB on windows and getting this error. This seems to be the right syntax, not sure why it isn't working. |
@dongemus what version of mariadb are you running? I am on 10.2.11. It should say it when you log into mysql or you can run the below from the command prompt.
Can you run these mysql commands for mariadb to see if your constraints are listed?
|
Thanks, I run 3 machines. I was trying it on the one that was on 10.1.28 and it showed
However, when I tried it on the machines running 10.2.8 and 10.2.9 it did show the CONSTRAINTs and the original commands worked. Looking forward to seeing the results! |
@dongemus Yes, you got the right results. Before MariaDB 10.2.1, constraint expressions were accepted in syntax, but ignored. So you would not show any on that one server. I updated my original comment to note that as my TTH search got smaller, so did the total 'latest_seen=3600' DB records. I was down to 26 after the night so this change should not cause any issues with searching. |
👍 Good catch. @Kneckter We've added this PR near the top of our todo list, but one thing it's missing is DB migration code to execute the change on old databases. Keep in mind the RM team is enjoying their holidays at the moment, so don't worry if it doesn't get done before New Year's. ❤️ |
But there is no reason to store 3600 it should store 0 instead the problem is in the code trying to store 3600 |
@friscoMad constraint 3 sets the latest seen to be >= 0 and constraint 4 sets it to be less than 3600. So it already stores 0 to 3599. Why shouldn't it store a 3600? Those spawn points exist and will be checked again for a TTH. |
earliest_unseen and latest_seen are the seconds from the hour when the spawn was present or not, this is to identify the type of spawn and the timing, so the value should always be from 0 to 3599, 3600 is the same as 0, but I am not sure why we are trying to store 3600 as I tried to locate where it is being set and it seems that the value always come from date_secs in util.py and that function should only return values from 0 to 3599 (unles a leap second occurs but I don't expect that to be the issue) so I must have skip some branch of code that leads to this situation. I will give it another try. |
Can you check in your logs with the issue if this line appears with 3600? |
I no longer have that log file but I saw someone post the logs in the help channel:
I can try recreating the constraint error over the weekend if you need more logs. |
#2423 has been closed for now. After investigating the scheduler, it seems The code is clear on requiring 3600 for
But it also has code requiring Edit: With the investigation finished, we've agreed (on Discord) to use the range We're not sure whether there are ever any negative numbers, but we preferred to make sure. |
Attempt just now. Fresh develop, pulled pr2416, ran an instance with -cd, ran a server only instance, fired up my main chunk, error and python crash, fired up a tiny test st4 and it works. Odd. |
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.
@Kneckter A DB migration to run the commands in the PR details would be great.
Hello @pogo-excalibur , you are talking about the python code for applying this to existing DBs? I have an idea about that but I am not sure how to rebase the file since I never use github. In the latest version of RM the DB was updated to version 21. So the code would look like this:
I have not tested this out yet but I can give it a shot later. |
@Kneckter 👍 That looks about right. Having that in will make it easier to test this. |
RM tries to write DB records with a 'latest_seen=3600'. Changing the Check statement allows for these records to be written instead of throwing "InternalError(4025, u'CONSTRAINT CONSTRAINT_4 failed for rocketmapdbadmin.spawnpoint')".
I rebased the code and added the DB migration. It worked on my test setup without an error.
Let me know if I messed something up with the rebase or the commit. |
Fell asleep before Travis finished lol. I used too long of lines since I'm not used to python. Updated my code and retested it on my small setup to ensure it still applied the changes. |
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.
Been running for 2 hours no issues on my main setup. Someone else will need to review the code as I'm not an expert.
Ran 12+ hours yesterday without issues, ran a -cd and restarted this morning. Been going good for 2 more hours. |
@jaake77 thanks for running the test! Has your TTH scan completed? The last half of the TTH scan is usually when the u'CONSTRAINT error came up. If it has not completed, will you check to see if it stored any 3600s with this mysql command: SELECT * FROM `rocketmapdb`.`spawnpoint` WHERE latest_seen>='3600' ORDER BY `latest_seen` DESC LIMIT 10; If it displays some records then you shouldn't expect any error by the time the TTH finishes. |
Looking good, it must have found TTHs for the ones you had. I ran two new areas last night and had no constraint errors. There are about 8 3600s in my spawnpoints right now. |
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.
Tests good. Did both with an existing DB and a -cd fresh one. Thanks for your work. Someone else needs to review code. Let me know if there are changes and you need more testing.
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.
No errors in console, spheal of approval!
Description
RM tries to write DB records with a 'latest_seen=3600' instead of 3599 like the constraint allows for. Changing the Check statement to '=<3600' allows for these records to be written instead of throwing "InternalError(4025, u'CONSTRAINT CONSTRAINT_4 failed for rocketmapdbadmin.spawnpoint')".
Note that this code change will not update existing DBs and will only apply the new constraint to maps that run the -cd flag.
An FAQ can be added if anyone wants to run the mysql commands to update their DB. The following commands should allow anyone to do it:
Motivation and Context
This error kept occurring on my map and many others. Most have seen this as a resource issue and the only solution was to decrease step size and run a -cd. Search the discord channels, there are 6 pages of results but no real solutions. If this is implemented, people will be able to run their large steps without having to restart a DB if they run into a constraint issue.
How Has This Been Tested?
Using Ubuntu 17.04 with the GUI desktop installed. Running a speedscan with an -st 200 geofenced to 36723 steps with 600 workers and 10 DB threads.
I have not tested the python code change, only the DB constraint commands.
I have been running this -st 200 with 50K spawnpoints started to get error 4025 when I hit about 75%. I pulled up HeidiSQL to see what was being written. Since I have spawnpoints with 'latest_seen=3599' and saw that RM wanted to write one with 'latest_seen=3600', I changed the constraint on the spawnpoints table with the above commands. Since then, I have not received the error and completed the initial scan. There are about 150 spawnpoints that have 'latest_seen=3600'.
As my TTH search got smaller, so did the total 'latest_seen=3600' DB records. I was down to 26 after a night so this change should not cause any issues with searching.
Screenshots (if appropriate):
Types of changes
Checklist: