sqlite3.OperationalError: database is locked
Hi, today I faced this issue second time on UA0001 camera, the first time was after big release so it is rare but sometimes happening and as result - no captured data for this night Maybe it could be somehow fixed.
The error log:
Traceback (most recent call last):
File "/home/pi/source/RMS/RMS/BufferedCapture.py", line 1198, in initVideoDevice
max_retries=5, retry_interval=1
File "/home/pi/source/RMS/RMS/BufferedCapture.py", line 934, in createGstreamDevice
device_url = self.extractRtspUrl(self.config.deviceID)
File "/home/pi/source/RMS/RMS/BufferedCapture.py", line 580, in extractRtspUrl
raise ValueError("No RTSP URL found in the input string: {}".format(input_string))
ValueError: No RTSP URL found in the input string: v4l2src device=/dev/video0 ! videoconvert ! video/x-raw,format=GRAY8 ! appsink sync=1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/source/RMS/RMS/BufferedCapture.py", line 1569, in run
while not self.exit.is_set() and not self.initVideoDevice():
File "/home/pi/source/RMS/RMS/BufferedCapture.py", line 1261, in initVideoDevice
conn = getObsDBConn(self.config)
File "/home/pi/source/RMS/RMS/Formats/ObservationSummary.py", line 96, in getObsDBConn
"""SELECT name FROM sqlite_master WHERE type = 'table' and name = 'records';""").fetchall()
sqlite3.OperationalError: database is locked
I'm also seeing the same issue on some systems. I'll put it on the stack, hopefully someone can look into it.
Hi,
Small analysis from me:
the root cause : connection locked by: ObservationSummary.startObservationSummaryReport
I checked db for this date and see that insertion to table records very slow (maybe sd card overloaded) and insert of all parameters takes - 12 seconds.
Possible solutions
- get connection with bigger timeout (default is 5 sec)
- add retry logic in case if db locked (i.e. 6 times - 30sec)
- add try/catch in place where it happened to continue capture process, but we lost
media_backendparameter in this case
If some one can advise what is the best option - I can prepare pull request with fix.
place for try/catch :
except Exception as e:
log.info("Error initializing GStreamer, switching to alternative. Error: {}".format(e))
self.media_backend_override = True
self.releaseResources()
add here ---> conn = getObsDBConn(self.config)
addObsParam(conn, "media_backend", self.video_device_type)
conn.close()
Times from DB:
Thanks for the report, I'll start looking into it.
Still working on this.