Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2020-08-17 21:14:27

neptho
Member
From: A cold, dark place.
Registered: 2006-02-01
Posts: 47

Re: Upgraded to 4.8.2; image uploads silently fail.

Bloke wrote #325438:

Not sure what we can do about this. We could somehow test the auto-increment value and the highest value stored in that table, and if the former is lower than the latter, either a) abort with a suitable error, or b) reset the auto-increment to one higher than the highest value and try again, hoping no other user has encountered the same problem at the same moment to enter a race condition.

Sounds time expensive and risky. Even though it should only ever need to happen once, the fact we’re checking for it every insert – and it only needs to be done if the table we’re operating upon has an auto_increment column – slows things down.

The other avenue is to make the test above a condition of the table checker in Diagnostics. That’s off the critical path and can test only the tables we know have such columns in them. It means people could potentially diagnose auto_increment issues when weird things happen, by checking the Diagnostics. I think that’s the sanest solution.

I’d be a bit annoyed, personally, if my last auto_increment ID was reset every time I inserted something and expected a new ID from something I had possibly deleted – but I’ve had the same DB schema since 2006. :)

My only real suggestion is to test after insertion if my_insert_id() isn’t === 0, or to test for the file path after upload to ensure it actually exists to ensure all is well, since TXP renames things numerically based upon that insert id, which is probably why the rename failed since the file rename literally nulled it, so it was ignored by the filesystem, AFAICT.

That said, I am not really sure HOW my tables got corrupt, but it was likely unrelated to the upgrade; just really weird that they got reset to 0 without any further DB instance changes upstream, although I have no 0 ID, so possibly a bit of weird logic; I haven’t checked any of the upgrade…php files to tell why since I was finally arsed to login and check for a reason. :)

Offline

#12 2020-08-24 08:57:20

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,269
Website

Re: Upgraded to 4.8.2; image uploads silently fail.

neptho wrote #325440:

I’d be a bit annoyed, personally, if my last auto_increment ID was reset every time I inserted something and expected a new ID from something I had possibly deleted – but I’ve had the same DB schema since 2006. :)

My only real suggestion is to test after insertion if my_insert_id() isn’t === 0, or to test for the file path after upload to ensure it actually exists to ensure all is well, since TXP renames things numerically based upon that insert id, which is probably why the rename failed since the file rename literally nulled it, so it was ignored by the filesystem, AFAICT.

That said, I am not really sure HOW my tables got corrupt, but it was likely unrelated to the upgrade; just really weird that they got reset to 0 without any further DB instance changes upstream, although I have no 0 ID, so possibly a bit of weird logic; I haven’t checked any of the _upgrade_…php files to tell why since I was finally arsed to login and check for a reason. :)

Highly recommended rss_db_manager. It helps catching some of the errors on time.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB