bernardodemarco opened a new pull request, #14678:
URL: https://github.com/apache/cloudstack/pull/14678

   ### Description
   
   PR #10140 introduced the `allocated_size` column to the `cloud.object_store` 
table, which is expected to hold the sum of all bucket quota, in bytes. To 
initialize the new column, the following query was introduced:
   
   
https://github.com/apache/cloudstack/blob/f8f3848321ae0791b472d1aeba7d0b057c83442f/engine/schema/src/main/resources/META-INF/db/schema-42040to42100.sql#L742-L749
   
   However, bucket quotas are stored in GiB, not bytes, and the query does not 
convert them. As a result, Object Storage providers in environments upgraded 
from versions prior to 4.21 have an `allocated_size` that is smaller than 
expected. When a bucket is deleted, its quota (converted to bytes) is 
subtracted from this value, which becomes negative. Since the column is 
unsigned, the update fails and the bucket cannot be deleted:
   
   <details>
   
   <summary>Impossibility of deleting buckets</summary>
   
   ```
   2026-11-10 16:10:07,939 ERROR [o.a.c.s.d.d.ObjectStoreDaoImpl] 
(qtp1404565079-3736:[ctx-3a285296, ctx-ce4f3b14]) (logid:78d41388) DB Exception 
on: HikariProxyPreparedStatement@1008598898 wrapping 
com.mysql.cj.jdbc.ServerPreparedStatement[21]: UPDATE object_store SET 
object_store.allocated_size=-536870912000 WHERE object_store.id = 2 
com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range 
value for column 'allocated_size' at row 1
        at 
com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104)
        at 
com.mysql.cj.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:555)
        at 
com.mysql.cj.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:339)
        at 
com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1061)
        at 
com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1009)
        at 
com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1320)
        at 
com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:994)
        at 
com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
   ```
   
   </details>
   
   Therefore, this PR recalculates the allocated size in bytes for each Object 
Storage provider. It targets the 4.22.2.0 version. A follow-up PR targeting 
`main` will apply the same fix to environments already running 4.23.0.0.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [X] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] Build/CI
   - [ ] Test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [X] Major
   - [ ] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   ### How Has This Been Tested?
   
   - Executed the normalization query locally and verified it recalculates 
correctly the allocated size for each Object Storage provider.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to