mycontroller-org / mycontroller-v1-legacy

The Open Source Controller
http://www.MyController.org
Apache License 2.0
148 stars 90 forks source link

settings VALUE2 VARCHAR(5000) limitation leads failure to save dashboard configuration #462

Closed jkandasa closed 6 years ago

jkandasa commented 6 years ago

Originally reported in https://forum.mycontroller.org/topic/326/i-can-t-add-a-widget-to-a-dashboard

When we have more numbers of widgets, configuration content size of the dashboard goes beyond 5000 chars, which leads failure to save changes from the user.

2018-08-07 07:56:28,603 ERROR [Acme.Utils.ThreadPool(0)-PooledThread: Acme.Serve.Serve$ServeConnection@7e16d33c] [org.mycontroller.standalone.db.dao.BaseAbstractDaoImpl:279] unable to update item:[Settings(id=106, userId=1, key=dashboard, subKey=5TwP2_1532941526658, value=Test 1, altValue=null, value2=***SKIPPED USERS DATA****, value3=3-9 (12/6-6), value4=null, value5=null): UPDATE `settings` SET `userId` = ?, `key` = ?, `subKey` = ?, `value` = ?, `altValue` = ?, `value2` = ?, `value3` = ?, `value4` = ?, `value5` = ? WHERE `id` = ?
    at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:25)
    at com.j256.ormlite.stmt.mapped.MappedUpdate.update(MappedUpdate.java:129)
    at com.j256.ormlite.stmt.StatementExecutor.update(StatementExecutor.java:472)
    at com.j256.ormlite.dao.BaseDaoImpl.update(BaseDaoImpl.java:409)
    at org.mycontroller.standalone.db.dao.BaseAbstractDaoImpl.update(BaseAbstractDaoImpl.java:276)
    at org.mycontroller.standalone.settings.SettingsUtils.updateSettings(SettingsUtils.java:78)
    at org.mycontroller.standalone.settings.Dashboard.update(Dashboard.java:65)
    at org.mycontroller.standalone.settings.Dashboard.update(Dashboard.java:61)
    at org.mycontroller.standalone.api.jaxrs.DashboardHandler.updateDashboard(DashboardHandler.java:102)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    at org.jboss.resteasy.plugins.server.tjws.TJWSServletDispatcher.service(TJWSServletDispatcher.java:40)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at Acme.Serve.Serve$ServeConnection.runServlet(Serve.java:2328)
    at Acme.Serve.Serve$ServeConnection.parseRequest(Serve.java:2282)
    at Acme.Serve.Serve$ServeConnection.run(Serve.java:2054)
    at Acme.Utils$ThreadPool$PooledThread.run(Utils.java:1402)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.h2.jdbc.JdbcSQLException: Value too long for column "VALUE2 VARCHAR(5000) SELECTIVITY 5": "'[{""columns"":[{""styleClass"":""col-md-3"",""widgets"":[{""type"":""mycSingleSensorGraph"",""config"":{""variableId"":""2"",""withMinMax"":false,""... (5251)"; SQL statement:
UPDATE `settings` SET `userId` = ?, `key` = ?, `subKey` = ?, `value` = ?, `altValue` = ?, `value2` = ?, `value3` = ?, `value4` = ?, `value5` = ? WHERE `id` = ? [22001-194]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.table.Column.validateConvertUpdateSequence(Column.java:335)
    at org.h2.table.Table.validateConvertUpdateSequence(Table.java:793)
    at org.h2.command.dml.Update.update(Update.java:125)
    at org.h2.command.CommandContainer.update(CommandContainer.java:101)
    at org.h2.command.Command.executeUpdate(Command.java:258)
    at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:160)
    at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:146)
    at com.j256.ormlite.jdbc.JdbcDatabaseConnection.update(JdbcDatabaseConnection.java:289)
    at com.j256.ormlite.jdbc.JdbcDatabaseConnection.update(JdbcDatabaseConnection.java:212)
    at com.j256.ormlite.stmt.mapped.MappedUpdate.update(MappedUpdate.java:101)
    ... 27 common frames omitted
jkandasa commented 6 years ago

This change is available in the SNAPSHOT version.