Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-116699

Data base cannot be opened in the subsequent launches

    XMLWordPrintable

Details

    • All
    • b67d3daa4 (dev), b3333de0a (6.5), ee5c6a034 (6.6), b3adcd2c6 (tqtc/lts-6.2), 473dfc600 (tqtc/lts-5.15)

    Description

      I haven't checked if this behavor can happen in all the versions in which Qt Insight Tracker is available. So, please check that point as well and fix them accordingly.

      In both desktop and RPI4, even though in the first launch the application can use the sql database correctly, in the subsequent launches it cannot. Therefore, it then start sending the events immediately without storing them to the data base.
       
      This happens when "storage_size" is set to more than 0.
      Here is the error message in the subsequent launches.

      qt.insight.storage: Using event storage: "/home/root/.local/share/QtProject/Gallery/hMzhLmSAJnhmvKWVUsum7RgMnjl0nfCWqtrnVXtRiae7cf58WSv1zQ6vmxc2b3SU.db"
      qt.insight.storage: Failed to create events table cleanup trigger with error: "trigger events_cleanup already exists Unable to execute statement"
      qt.insight.storage: Failed to open the SQLITE storage
      qt.insight.events: New event (733 bytes) {"aid":"Gallery","co":"{\"data\":[{\"data\":{\"model\":\"Raspberry Pi 4 Qt 6.5.0\",\"screen_resolution\":\"1280x720\",\"screen_type\":\"NON_TOUCH\",\"variant\":\"v\"},\"schema\":\"iglu:io.qt/device/jsonschema/1-0-0\"},{\"data\":{\"build\":\"1.2.3\",\"last_shutdown\":false,\"qt_version\":\"6.5.0\",\"version\":\"\"},\"schema\":\"iglu:io.qt/application/jsonschema/1-0-1\"}],\"schema\":\"iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0\"}","dtm":"1693576365423","duid":"13006c2b-ed1d-4a9b-886d-b107f15d5494","e":"ue","eid":"d72e94bb-e1c0-4c08-9df7-57b70f08a5d0","lang":"en_US","p":"iot","sid":"7e33d4e8-8e7d-4574-a530-48a6ca3edcec","tna":"hMzhLmSAJnhmvKWVUsum7RgMnjl0nfCWqtrnVXtRiae7cf58WSv1zQ6vmxc2b3SU","tv":"qt-1.0.0"}
      qt.insight.events: Storage is not available, sending event immediately.
      qt.insight.events: Sending 1 events in 733 bytes
      qt.insight.events: Events have been sent successfully. 

      Notice that in line 2 and 3, it fails to open the db and then as a result, ends up sending the data immediately without using db(line 5).

      Apparently this operation fails every time in the subsequent launches.

      // qsqlitestorage.cpp
      const auto createTriggerQuery =
                      QLatin1String("CREATE TRIGGER %1 AFTER INSERT ON %2 "
                                    "BEGIN "
                                    "DELETE FROM %3 WHERE id NOT IN "
                                    "(SELECT %4 FROM %5 ORDER BY %6 DESC LIMIT %7 ); "
                                    "END")
                              .arg(EVENTS_TRIGGER_NAME, EVENTS_TABLE_NAME, EVENTS_TABLE_NAME,
                                   EVENTS_TABLE_ID, EVENTS_TABLE_NAME, EVENTS_TABLE_ID)
                              .arg(m_maxRecords); 

      When it fails, the enclosing function returns false, which leads to the error message :

       qCWarning(lcQInsightConfig) << "Could no open configuration file" << configPath; 

      in QInsightConfiguration::load() in the file qinsightconfiguration.cpp.

      Failed to create events table cleanup trigger with error: "trigger events_cleanup already exists Unable to execute statement 

      But actually the last part is coming from the actual error message from the database apparently, like so.

      qCWarning(lcInsightStorage)
      
                          << "Failed to create events table cleanup trigger with error:"
      
                          << query.lastError().text(); 

      And the error message makes sense too. Because "trigger events cleanup" should exist in the subsequent launches so maybe we should not treat this case as error, otherwise the application cannot rely on the storage in the subsequent launches.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sapiippo Samuli Piippo
            mikio_hirai Mikio Hirai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes