Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Error: cursor already closed #82

Closed
3 tasks done
obervinov opened this issue Jul 19, 2024 · 0 comments · Fixed by #90
Closed
3 tasks done

Bug: Error: cursor already closed #82

obervinov opened this issue Jul 19, 2024 · 0 comments · Fixed by #90
Assignees
Labels
bug Something isn't working
Milestone

Comments

@obervinov
Copy link
Owner

obervinov commented Jul 19, 2024

Describe the bug
Errors related to the inability to connect to the database became more frequent.
Error message:

[2024-07-19 12:03:13,331] INFO [logger.logger:authorization:363] [class.Users] Check role `reschedule_queue` for user `123456789`: allowed
[2024-07-19 12:03:13,574] ERROR [logger.logger:handle:27] [Bot]: Error: cursor already closed
Exception in thread WorkerThread2:
Traceback (most recent call last):
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/util.py", line 93, in run
    task(*args, **kwargs)
  File "/home/pyinstabot-downloader/app/src/bot.py", line 466, in reschedule_queue
    database.update_schedule_time_in_queue(
  File "/home/pyinstabot-downloader/app/src/modules/database.py", line 522, in update_schedule_time_in_queue
    self._update(
  File "/home/pyinstabot-downloader/app/src/modules/database.py", line 291, in _update
    self.cursor.execute(f"UPDATE {table_name} SET {values} WHERE {condition}")
psycopg2.InterfaceError: cursor already closed

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/threading.py", line 980, in _bootstrap_inner
    self.run()
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/util.py", line 103, in run
    self.exception_callback(self, self.exception_info)
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/util.py", line 140, in on_exception
    handled = self.telebot.exception_handler.handle(exc_info)
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telegram/telegram.py", line 28, in handle
    raise FailedToCreateInstance("Failed to create the bot instance.") from exception
telegram.exceptions.FailedToCreateInstance: Failed to create the bot instance.

Additional context
Information about where the bug is happening:
None

Possible correction

  • Attempt to recreate the connection and courses if an exception occurs
  • Make sure that course closure is caused by external circumstances and not by a code error when the course is closed programmatically

Screenshots
None

Check list after fixing the bug

  • Cursor closing is no longer a critical error causing bot threads to crash
@obervinov obervinov added the bug Something isn't working label Jul 19, 2024
@obervinov obervinov self-assigned this Jul 19, 2024
@obervinov obervinov changed the title Bug: Error: cursor already closed Bug: Error: cursor already closed Jul 19, 2024
@obervinov obervinov added this to the v2.1.9 milestone Jul 22, 2024
@obervinov obervinov modified the milestones: v2.1.9, v2.2.0 Aug 15, 2024
@obervinov obervinov added this to the v2.2.0 milestone Aug 16, 2024
obervinov added a commit that referenced this issue Aug 19, 2024
obervinov added a commit that referenced this issue Aug 20, 2024
… bug fixes (#90)

## v2.2.0 - 2024-08-20
### What's Changed
**Full Changelog**: v2.1.8...v2.2.0 by @obervinov in #90
#### 🐛 Bug Fixes
* #86
* #85
* #84
* #83
* #82
* #65
#### 🚀 Features
* bump workflow version to `1.2.8`
* #81
* #53
* #66
* Add GH Actions Job for cleanup untagged images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
1 participant