dosubot[bot] commented on issue #33605: URL: https://github.com/apache/superset/issues/33605#issuecomment-2916472863
<!-- Answer --> The error you're seeing—`StaleDataError: DELETE statement on table 'tagged_object' expected to delete 2 row(s); Only 4 were matched`—indicates a data consistency issue in the `tagged_object` table. This happens when SQLAlchemy expects to delete a certain number of rows (based on its session state), but the actual number of rows affected in the database is different. This often points to duplicate or orphaned records, or concurrent modifications. In Superset, the `tagged_object` table is used to associate tags with dashboards, charts, and other objects. It has a unique constraint on the combination of `tag_id`, `object_id`, and `object_type` to prevent duplicates, but if this constraint is violated or if there are unexpected extra rows, deletion can fail with a `StaleDataError` as you've seen. The deletion logic for dashboards attempts to remove related rows from `tagged_object` based on `object_type` and `object_id`—if more rows exist than expected, this error will occur ([source](https://github.com/apache/superset/blob/master/superset/tags/models.py)). To resolve this, check your `tagged_object` table for duplicate or inconsistent entries related to the dashboard you are trying to delete. You can do this by running a query like: ```sql SELECT * FROM tagged_object WHERE object_id = <dashboard_id> AND object_type = 'dashboard'; ``` If you find duplicate or unexpected rows, you may need to clean them up manually to restore consistency. After cleaning up, try deleting the dashboard again. No similar issues or recent changes related to this specific error were found in the Superset repository. If this problem recurs, it may indicate a bug in how tags are managed or deleted for dashboards, especially if dashboards are created and deleted in rapid succession or via automation. If you continue to encounter this, consider capturing the exact state of the `tagged_object` table before deletion and sharing it for further analysis. <!-- Dosu Comment Footer --> *To reply, just mention my name [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/faf367f9-30da-4ce5-a877-c6001d34a583?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/faf367f9-30da-4ce5-a877-c6001d34a583?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/faf367f9-30da-4ce5-a877-c6001d34a583?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/faf367f9-30da-4ce5-a877-c6001d34a583?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/faf367f9-30da-4ce5-a877-c6001d34a583?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/faf367f9-30da-4ce5-a877-c6001d34a583?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/faf367f9-30da-4ce5-a877-c6001d34a583?feedback_type=other)</sup> [](https://go.dosu.dev/discord-bot) [! [Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/33605) -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
