cwhelchel/hunterlog

Database locked error when logging.

Closed this issue · 0 comments

Describe the bug
Occurred with logging a normal QSO. This maybe an issue with logging while refreshing... but not sure. A fix for #11 would help to alert the user that some error occured. Logging the QSO a second time worked as expected.

Javascript console:

Uncaught (in promise) Traceback (most recent call last):
  File "webview\util.py", line 194, in _call
  File "api.py", line 248, in log_qso
UnboundLocalError: local variable 'id' referenced before assignment

index.log

<snip>

2024-04-07 13:13:25,441 = DEBUG   [api]: sending spot for KO4IZK on 7212
2024-04-07 13:13:25,453 = DEBUG   [urllib3.connectionpool]: Starting new HTTPS connection (1): api.pota.app:443
2024-04-07 13:13:25,535 = DEBUG   [urllib3.connectionpool]: https://api.pota.app:443 "GET /park/US-3728 HTTP/1.1" 200 392
2024-04-07 13:13:25,541 = DEBUG   [api]: updating park stat for: {'parkId': 3728, 'reference': 'US-3728', 'name': 'Providence Canyon', 'latitude': 32.0644, 'longitude': -84.9219, 'grid4': 'EM72', 'grid6': 'EM72mb', 'parktypeId': 101, 'active': 1, 'parkComments': None, 'accessibility': None, 'sensitivity': None, 'accessMethods': 'Automobile,Foot', 'activationMethods': 'Automobile,Pedestrian,Shelter', 'agencies': None, 'agencyURLs': None, 'parkURLs': None, 'website': 'https://gastateparks.org/ProvidenceCanyon', 'createdByAdmin': None, 'parktypeDesc': 'State Park', 'locationDesc': 'US-GA', 'locationName': 'Georgia', 'entityId': 291, 'entityName': 'United States of America', 'referencePrefix': 'US', 'entityDeleted': 0, 'firstActivator': 'AD4XT', 'firstActivationDate': '2019-02-10'}
2024-04-07 13:13:25,550 = DEBUG   [root]: increment hunts for park US-3728
2024-04-07 13:13:25,937 = DEBUG   [urllib3.connectionpool]: https://api.pota.app:443 "POST /spot/ HTTP/1.1" 200 10330
2024-04-07 13:13:25,939 = DEBUG   [potaApi]: code: 200 : OK
2024-04-07 13:13:31,087 = ERROR   [api]: Error logging QSO to db:
2024-04-07 13:13:31,087 = ERROR   [api]: (sqlite3.OperationalError) database is locked
[SQL: UPDATE parks SET hunts=?, last=CURRENT_TIMESTAMP WHERE parks.id = ?]
[parameters: (1, 2571)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Traceback (most recent call last):
  File "sqlalchemy\engine\base.py", line 1960, in _exec_single_context
  File "sqlalchemy\engine\default.py", line 924, in do_execute
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "api.py", line 238, in log_qso
  File "db\park_query.py", line 109, in inc_park_hunt
  File "sqlalchemy\orm\scoping.py", line 597, in commit
  File "sqlalchemy\orm\session.py", line 1972, in commit
  File "<string>", line 2, in commit
  File "sqlalchemy\orm\state_changes.py", line 139, in _go
  File "sqlalchemy\orm\session.py", line 1257, in commit
  File "<string>", line 2, in _prepare_impl
  File "sqlalchemy\orm\state_changes.py", line 139, in _go
  File "sqlalchemy\orm\session.py", line 1232, in _prepare_impl
  File "sqlalchemy\orm\session.py", line 4296, in flush
  File "sqlalchemy\orm\session.py", line 4432, in _flush
  File "sqlalchemy\util\langhelpers.py", line 146, in __exit__
  File "sqlalchemy\orm\session.py", line 4392, in _flush
  File "sqlalchemy\orm\unitofwork.py", line 466, in execute
  File "sqlalchemy\orm\unitofwork.py", line 642, in execute
  File "sqlalchemy\orm\persistence.py", line 85, in save_obj
  File "sqlalchemy\orm\persistence.py", line 912, in _emit_update_statements
  File "sqlalchemy\engine\base.py", line 1408, in execute
  File "sqlalchemy\sql\elements.py", line 513, in _execute_on_connection
  File "sqlalchemy\engine\base.py", line 1630, in _execute_clauseelement
  File "sqlalchemy\engine\base.py", line 1839, in _execute_context
  File "sqlalchemy\engine\base.py", line 1979, in _exec_single_context
  File "sqlalchemy\engine\base.py", line 2335, in _handle_dbapi_exception
  File "sqlalchemy\engine\base.py", line 1960, in _exec_single_context
  File "sqlalchemy\engine\default.py", line 924, in do_execute
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
[SQL: UPDATE parks SET hunts=?, last=CURRENT_TIMESTAMP WHERE parks.id = ?]
[parameters: (1, 2571)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
2024-04-07 13:13:33,677 = DEBUG   [root]: refreshing spots in frontend: window.pywebview.state.getSpots()
2024-04-07 13:13:33,685 = DEBUG   [api]: py get_spots
2024-04-07 13:13:33,868 = DEBUG   [api]: getting activator stats...
2024-04-07 13:13:33,869 = DEBUG   [db]: get_activator() basecall N3VAN
2024-04-07 13:13:33,874 = INFO    [api]: activator needs update from POTA API...

<snip>

Desktop (please complete the following information):

  • OS: Windows
  • Hunterlog application version: 0.0.2
  • Hunterlog database version: 922a7b854b71

Additional context
Was a normal SSB contact with an activator frequently hunted. Was just a new-to-me park.