Title: Netty IllegalReferenceCountException causes false upload failure despite successful upload · Issue #12489 · apache/cloudstack · GitHub
Open Graph Title: Netty IllegalReferenceCountException causes false upload failure despite successful upload · Issue #12489 · apache/cloudstack
X Title: Netty IllegalReferenceCountException causes false upload failure despite successful upload · Issue #12489 · apache/cloudstack
Description: problem Related Issue Related to #12486 Summary When uploading templates/ISOs from local file via the UI, the upload completes successfully on the SSVM (file is written to disk, SSVM returns HTTP 200 "upload successful"), but a Netty Ill...
Open Graph Description: problem Related Issue Related to #12486 Summary When uploading templates/ISOs from local file via the UI, the upload completes successfully on the SSVM (file is written to disk, SSVM returns HTTP 2...
X Description: problem Related Issue Related to #12486 Summary When uploading templates/ISOs from local file via the UI, the upload completes successfully on the SSVM (file is written to disk, SSVM returns HTTP 2...
Opengraph URL: https://github.com/apache/cloudstack/issues/12489
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Netty IllegalReferenceCountException causes false upload failure despite successful upload","articleBody":"### problem\n\n**Related Issue**\nRelated to https://github.com/apache/cloudstack/issues/12486\n\n**Summary**\nWhen uploading templates/ISOs from local file via the UI, the upload completes successfully on the SSVM (file is written to disk, SSVM returns HTTP 200 \"upload successful\"), but a Netty IllegalReferenceCountException occurs during response handling. This causes the UI to display an error to the user even though the upload actually succeeded. The template eventually becomes \"Ready\" after background processing completes.\n\n### versions\n\nCloudStack Version 4.20.2.0\n\n### The steps to reproduce the bug\n\n1. Navigate to Images → Templates\n2. Click \"Upload Template from local\"\n4. Fill in the form and submit\n5. Watch browser Network tab - upload returns 200 OK\n6. Check browser Console - may show error despite 200 OK\n7. Check SSVM logs - see Netty IllegalReferenceCountException\n8. Wait - template eventually becomes Ready\n\nNote: This issue is intermittent.\n\n**Expected Behavior**\nWhen the upload succeeds (HTTP 200, file written to disk), the UI should show success to the user.\n\n**Actual Behavior**\n\n- Upload succeeds (HTTP 200, \"upload successful\")\n- File is written to disk correctly\n- Netty throws IllegalReferenceCountException during cleanup\n- UI may show error to user (HTTP 432 in some cases)\n- Template eventually becomes Ready after background processing\n\n\n**Impact**\n\n- User confusion: User sees error but upload actually worked\n- Duplicate uploads: User may retry, creating duplicate templates\n- Wasted time: User troubleshoots non-existent problem\n\n\n**Root Cause Analysis**\nThe IllegalReferenceCountException occurs in `HttpUploadServerHandler.channelUnregistered()` when trying to destroy the `HttpPostRequestDecoder`. The decoder's reference count has already reached 0, indicating it was already released elsewhere.\nThis is a reference counting bug in the Netty upload handler - the decoder is being released twice:\n\n- Once during normal processing\n- Again in `channelUnregistered()` cleanup\n\n**Evidence**\n\nBrowser Network Tab - Upload Succeeded (HTTP 200)\nRequest Headers (all correct):\n\n```\nX-Expires: 2026-01-21T16:46:06.391Z\nX-Metadata: 7d9tasmSFbD/i/a+7cIPVHUKLB5oZUTfHOf6nIwEo6gdgJ1IHcgXfSHe1TouKFGRARpVRJJyyfVX5fqGcsv14oYurocRB4KGOkuW6zfW3GZC3hxhM2vA5OjK5Q497cxlc/TkgD/BOYoyx3VS32w4jFFxfVty9YSrc2tx1/bo9kE4MFXbFiuGNHI799xK8WhEXiTuR/7iyxRqLM17+ql/JYxlPLSP7DWbVOMFwm7HACbmSSaUNyJhi2OiaOmmU0TC5jpezvLxXhVmDsl9Fe9/uhTG2PDtmd/d2L+QtQz8+zNqxwgrS8EJqJKsk7q7tPzoDFKWc7Qp0uYpPvMqpyd377kXA2qhKnphEKrB6rBvIHV0OaX071UMNSysfrYC+GOIi3smUK6p5x939GlNlVFI6kYM5pkVZ9AsuNzGii4SMDZc8UGYrYmhazT10+ye0IlAVw5cFu5hcwVmeGnK8O2xDQkHo1z5wFYxiqCzZSuVdrhk0jdV0ktZ0CAcQeZzjBblu4DWFCcdqRDHl+8SkeAwtUjV3ZDht0u4D1lQdgV4G/NeDPCPhkm61WhKcR4AHvq5pb1+bs9h/8+b2BkuhfNbdNCd/gjW2kMsl4KcbhQwB+3uQsxZ9srg+hKacPB2Cyd8kgdLzuC4zYBq8mv8pRg4gpj5fbVC5Vs7pYbzpDlfoeIAuCZS7pDJM4Jontlae/QoGGo5\nX-Signature: zw+vnaAEiYNsjUfHov44KNZ/GBw=\nContent-Length: 400621794\n```\n\n- Response:\n\n```\nStatus Code: 200 OK\nBody: upload successful.\n```\n\n- SSVM Logs (/var/log/cloud.log) - Upload Received and Processed\n\n```\n2026-01-21T15:46:06,551 INFO [storage.resource.HttpUploadServerHandler] (nioEventLoopGroup-3-6:[]) HEADER: SIGNATURE=zw+vnaAEiYNsjUfHov44KNZ/GBw=\n2026-01-21T15:46:06,552 INFO [storage.resource.HttpUploadServerHandler] (nioEventLoopGroup-3-6:[]) HEADER: METADATA=7d9tasmSFbD/i/a+7cIPVHUKLB5oZUT...\n2026-01-21T15:46:06,552 INFO [storage.resource.HttpUploadServerHandler] (nioEventLoopGroup-3-6:[]) HEADER: EXPIRES=2026-01-21T16:46:06.391Z\n2026-01-21T15:46:06,552 INFO [storage.resource.HttpUploadServerHandler] (nioEventLoopGroup-3-6:[]) HEADER: HOST=10.0.56.181\n2026-01-21T15:46:06,553 INFO [storage.resource.HttpUploadServerHandler] (nioEventLoopGroup-3-6:[]) HEADER: CONTENT_LENGTH=400621794\n2026-01-21T15:46:06,554 INFO [storage.resource.HttpUploadServerHandler] (nioEventLoopGroup-3-6:[]) URI: uuid=6c80606a-8826-460f-88a8-c15ed3606a6c\n2026-01-21T15:46:06,555 INFO [storage.resource.HttpUploadServerHandler] (nioEventLoopGroup-3-6:[]) base directory: /mnt/SecStorage/5f75abe3-3803-3595-89ad-52d23b3dea97/template/tmpl/2/203\n2026-01-21T15:46:06,611 INFO [storage.resource.HttpUploadServerHandler] (nioEventLoopGroup-3-6:[]) BODY: FileUpload: name=\"file\"; filename=\"linux-debian-11-x86_64-gen2-v1.qcow2\"\n```\n\n- SSVM Logs - Netty Exception During Cleanup\n\n```\n2026-01-21T15:47:30,572 WARN [storage.resource.HttpUploadServerHandler] (nioEventLoopGroup-3-6:[]) \nDecoder already destroyed \nio.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1\n at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:83)\n at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:140)\n at io.netty.util.AbstractReferenceCounted.release(AbstractReferenceCounted.java:79)\n at io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.destroy(HttpPostRequestDecoder.java:293)\n at org.apache.cloudstack.storage.resource.HttpUploadServerHandler.channelUnregistered(HttpUploadServerHandler.java:169)\n```\n\n- File Successfully Written to SSVM\n\n```\nroot@s-1-VM:~# ls -la /mnt/SecStorage/5f75abe3-3803-3595-89ad-52d23b3dea97/template/tmpl/2/203/\ntotal 391236\ndrwxrwxrwx 2 root root 95 Jan 21 2026 .\ndrwxr-xr-x 3 root root 25 Jan 21 2026 ..\n-rw-rw-rw- 1 root root 400621568 Jan 21 2026 c620128e-31ef-31ec-a04a-24104a89fdf0.qcow2\n-rw-rw-rw- 1 root root 340 Jan 21 2026 template.properties\n```\n\n- Template Properties File Created\n\n```\nroot@s-1-VM:~# cat /mnt/SecStorage/5f75abe3-3803-3595-89ad-52d23b3dea97/template/tmpl/2/203/template.properties\n#\n#Wed Jan 21 15:47:30 UTC 2026\nuniquename=203-2-0cb72ddc-d73a-3f2c-9f1f-24af1d033391\nqcow2.filename=c620128e-31ef-31ec-a04a-24104a89fdf0.qcow2\nqcow2.virtualsize=5368709120\ndescription=test\nqcow2.size=400621568\nfilename=c620128e-31ef-31ec-a04a-24104a89fdf0.qcow2\nsize=400621568\npublic=true\nid=203\nhvm=true\nvirtualsize=5368709120\nqcow2=true\n```\n\n- Despite the error shown to the user, the template eventually became Ready:\n\n```\n{\n \"id\": \"6c80606a-8826-460f-88a8-c15ed3606a6c\",\n \"name\": \"Debian 11\",\n \"isready\": true,\n \"status\": \"Download Complete\",\n \"downloaddetails\": [\n {\n \"datastore\": \"NFS://10.0.32.4/acs/secondary/ref-trl-10677-k-Mr8-rositsa-kyuchukova/ref-trl-10677-k-Mr8-rositsa-kyuchukova-sec1\",\n \"downloadPercent\": \"100\",\n \"downloadState\": \"DOWNLOADED\"\n }\n ],\n \"physicalsize\": 400621568,\n \"size\": 5368709120\n}\n```\n\n### What to do about it?\n\nIn H`ttpUploadServerHandler.java`, add a null check or try-catch around the decoder destruction in `channelUnregistered()`\n\n**Workaround**\n\nIgnore the error in the UI and wait - template will eventually become Ready\nRefresh the template list after a minute to see actual status","author":{"url":"https://github.com/RosiKyu","@type":"Person","name":"RosiKyu"},"datePublished":"2026-01-21T18:22:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/12489/cloudstack/issues/12489"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5ff8bc69-89c2-08d9-cff4-81d0a5aa3156 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D06:3BEDBF:1119DD8:17B11A4:6A4DDE0A |
| html-safe-nonce | 0f33acfe461ebd763bc348b6ad4c0a26e3bc8ca81d65c27bcdc2bd4d04445143 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDA2OjNCRURCRjoxMTE5REQ4OjE3QjExQTQ6NkE0RERFMEEiLCJ2aXNpdG9yX2lkIjoiODU4ODEwMjg0NjA2NjMxODg1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4af57ffdb1545d66203efc2a29a617a419050763a38d14e15bb795ffb6af3e0d |
| hovercard-subject-tag | issue:3839483924 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/apache/cloudstack/12489/issue_layout |
| twitter:image | https://opengraph.githubassets.com/80f611250c55fea9ce1ccc7098fcffdb160aeb53e744aae10e87ac692d94da8c/apache/cloudstack/issues/12489 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/80f611250c55fea9ce1ccc7098fcffdb160aeb53e744aae10e87ac692d94da8c/apache/cloudstack/issues/12489 |
| og:image:alt | problem Related Issue Related to #12486 Summary When uploading templates/ISOs from local file via the UI, the upload completes successfully on the SSVM (file is written to disk, SSVM returns HTTP 2... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RosiKyu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/apache/cloudstack git https://github.com/apache/cloudstack.git |
| octolytics-dimension-user_id | 47359 |
| octolytics-dimension-user_login | apache |
| octolytics-dimension-repository_id | 9759448 |
| octolytics-dimension-repository_nwo | apache/cloudstack |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 9759448 |
| octolytics-dimension-repository_network_root_nwo | apache/cloudstack |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width