ERROR: Auto Attendance Background Job 'Failed'

The Auto Attendance background job “shift_type.process_auto_attendance_for_all_shifts” keep failing and giving me the following error:

Traceback (most recent call last):
  File "apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py", line 85, in execute
    frappe.get_attr(self.method)()
  File "apps/erpnext/erpnext/hr/doctype/shift_type/shift_type.py", line 174, in process_auto_attendance_for_all_shifts
    doc.process_auto_attendance()
  File "apps/erpnext/erpnext/hr/doctype/shift_type/shift_type.py", line 67, in process_auto_attendance
    self.mark_absent_for_dates_with_no_attendance(employee)
  File "apps/erpnext/erpnext/hr/doctype/shift_type/shift_type.py", line 142, in mark_absent_for_dates_with_no_attendance
    attendance = mark_attendance(employee, date, "Absent", self.name)
  File "apps/erpnext/erpnext/hr/doctype/attendance/attendance.py", line 195, in mark_attendance
    attendance.insert()
  File "apps/frappe/frappe/model/document.py", line 255, in insert
    self._validate_links()
  File "apps/frappe/frappe/model/document.py", line 899, in _validate_links
    invalid_links, cancelled_links = self.get_invalid_links()
  File "apps/frappe/frappe/model/base_document.py", line 633, in get_invalid_links
    values = frappe.db.get_value(doctype, docname, values_to_fetch, as_dict=True)
  File "apps/frappe/frappe/database/database.py", line 459, in get_value
    ret = self.get_values(
  File "apps/frappe/frappe/database/database.py", line 531, in get_values
    out = self._get_values_from_table(
  File "apps/frappe/frappe/database/database.py", line 726, in _get_values_from_table
    r = self.sql(
  File "apps/frappe/frappe/database/database.py", line 174, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.8/site-packages/pymysql/cursors.py", line 148, in execute
    result = self._query(query)
  File "env/lib/python3.8/site-packages/pymysql/cursors.py", line 310, in _query
    conn.query(q)
  File "env/lib/python3.8/site-packages/pymysql/connections.py", line 547, in query
    self._execute_command(COMMAND.COM_QUERY, sql)
  File "env/lib/python3.8/site-packages/pymysql/connections.py", line 814, in _execute_command
    self._write_bytes(packet)
  File "env/lib/python3.8/site-packages/pymysql/connections.py", line 754, in _write_bytes
    self._sock.settimeout(self._write_timeout)
  File "env/lib/python3.8/site-packages/rq/timeouts.py", line 63, in handle_death_penalty
    raise self._exception('Task exceeded maximum timeout value '
rq.timeouts.JobTimeoutException: Task exceeded maximum timeout value (300 seconds)

Now it become this error:

Traceback (most recent call last):
  File "apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py", line 85, in execute
    frappe.get_attr(self.method)()
  File "apps/erpnext/erpnext/hr/doctype/shift_type/shift_type.py", line 174, in process_auto_attendance_for_all_shifts
    doc.process_auto_attendance()
  File "apps/erpnext/erpnext/hr/doctype/shift_type/shift_type.py", line 67, in process_auto_attendance
    self.mark_absent_for_dates_with_no_attendance(employee)
  File "apps/erpnext/erpnext/hr/doctype/shift_type/shift_type.py", line 144, in mark_absent_for_dates_with_no_attendance
    frappe.get_doc(
  File "apps/frappe/frappe/model/document.py", line 291, in insert
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1100, in run_post_save_methods
    self.save_version()
  File "apps/frappe/frappe/model/document.py", line 1217, in save_version
    version.insert(ignore_permissions=True)
  File "apps/frappe/frappe/model/document.py", line 291, in insert
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1096, in run_post_save_methods
    self.notify_update()
  File "apps/frappe/frappe/model/document.py", line 1124, in notify_update
    frappe.publish_realtime(
  File "apps/frappe/frappe/__init__.py", line 1928, in publish_realtime
    return frappe.realtime.publish_realtime(*args, **kwargs)
  File "apps/frappe/frappe/realtime.py", line 85, in publish_realtime
    if not params in frappe.local.realtime_log:
  File "env/lib/python3.8/site-packages/rq/timeouts.py", line 63, in handle_death_penalty
    raise self._exception('Task exceeded maximum timeout value '
rq.timeouts.JobTimeoutException: Task exceeded maximum timeout value (300 seconds)