We've currently disabled transactions on MySQL because they were causing concurrency problems, so a non-transaction solution would be preferrable.
It looks like currently, we update the user's quota by calling the User::quota_add($bytes) function, which adds a file's size to the usr.quotaused field. We could lessen the impact of this bug if we instead summed up the size of all the user's files. Preferrably in a single query, something like (although I'm not sure if this would be kosher in MySQL): UPDATE usr u SET quotaused = ( SELECT sum(aff.size) FROM artefact_file_files aff INNER JOIN artefact a ON a.id = aff.artefact WHERE a.owner = u.id ) WHERE u.id = ? Of course you could still get race conditions, but they'd only last until the next pageload when we do "SELECT * FROM usr" (assuming that I am correctly remembering that we do that on each page and don't cache it in the session). -- You received this bug notification because you are a member of Mahara Contributors, which is subscribed to Mahara. Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it! https://bugs.launchpad.net/bugs/1606749 Title: Inconsistent file quota usage Status in Mahara: Confirmed Bug description: Mahara: 16.04.2 DB: Postgres OS: Linux Browser: various File quota calculations are not syncing correctly for file upload when using multiple devices at the same time. This lets users surpass their quota by using different computers at the same time. I've also been able to replicate it by uploading multiple files at once. The usr.quotaused field doesn't get correctly accumulated after each file as it gets overwritten by the other file getting loaded. Perhaps a transaction is required? The cron job at the end of the day calculates the quota correctly but by then, the user has uploaded many times more than their quota For example, we were getting numbers such as 244% of their 500MB quota. To manage notifications about this bug go to: https://bugs.launchpad.net/mahara/+bug/1606749/+subscriptions _______________________________________________ Mailing list: https://launchpad.net/~mahara-contributors Post to : mahara-contributors@lists.launchpad.net Unsubscribe : https://launchpad.net/~mahara-contributors More help : https://help.launchpad.net/ListHelp