You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] GET /channels/{channelId}/statistics intermittently returns 500 during undeploy of an unrelated channel #457
In one thread, loop: deploy channel B, send a message through it, remove channel B.
In another thread, loop: GET /channels/{A}/statistics. GET /channels/statistics?channelId={A}&includeUndeployed=true fails the same way.
Expected:
A request naming channel A reads only what it needs to answer about channel A.
Actual:
Each request reads D_MS<n> for every channel the server knows about, A or not.
Roughly one request in forty fails with HTTP 500 under the loop above.
The server log shows DonkeyDaoException: java.sql.SQLSyntaxErrorException: Table/View 'D_MS<n>' does not exist,
for the channel being removed, not for A.
The client sees only {"message":"Request failed.","status":"500"}, because serialising the SQLException into the error response throws as well.
#516 fixes this for requests scoped to specific channels: they now read only those channels' statistics tables. Unscoped requests (e.g. GET /channels/statistics?includeUndeployed=true) still loop over every local channel in JdbcDao.getChannelStatistics and can still fail while a channel is being removed, so this issue should stay open after #516 merges.
Notes for whoever picks up the rest. The obvious fix, catching the exception and skipping that channel, is not enough on its own:
PostgreSQL needs a rollback. Read connections run with auto-commit off, so on PostgreSQL one failed query aborts the transaction, and every later query in the loop fails ("current transaction is aborted") until it is rolled back. Skipping a channel means rolling back (or using a savepoint) and then continuing.
Detecting a dropped table isn't portable. There's no common SQL state for "table does not exist" across our five databases, and matching messages is fragile. A more reliable check is to re-query D_CHANNELS after a failure and skip the channel only if it's no longer there, rethrowing otherwise. The DAO's cached getLocalChannelIds() map can't be used for this, because it's loaded once per DAO and won't show a removal that happens mid-loop.
It needs testing on every database. Locking around DROP TABLE differs between Derby, PostgreSQL, MySQL, SQL Server and Oracle, so the race may show up as an error on some and as a wait on others. A fix should be checked on all five.
Activity
Fix statistics errors caused by channel ID scoping
Fix statistics errors caused by channel ID scoping
Fix statistics errors caused by channel ID scoping
tonygermano commentedon Nov 26, 2026
#516 fixes this for requests scoped to specific channels: they now read only those channels' statistics tables. Unscoped requests (e.g.
GET /channels/statistics?includeUndeployed=true) still loop over every local channel inJdbcDao.getChannelStatisticsand can still fail while a channel is being removed, so this issue should stay open after #516 merges.Notes for whoever picks up the rest. The obvious fix, catching the exception and skipping that channel, is not enough on its own:
D_CHANNELSafter a failure and skip the channel only if it's no longer there, rethrowing otherwise. The DAO's cachedgetLocalChannelIds()map can't be used for this, because it's loaded once per DAO and won't show a removal that happens mid-loop.DROP TABLEdiffers between Derby, PostgreSQL, MySQL, SQL Server and Oracle, so the race may show up as an error on some and as a wait on others. A fix should be checked on all five.