X mouse "device removed" problem

So for about two, maybe three weeks I have noticed that every so often my desktop seems to freeze for a moment (a second or two) and then go back to normal. The symptoms were that the mouse pointer stopped moving and wouldn’t accept input (e.g. the scroll wheel). Finally after keeping a process list open for a while I noticed that each time this happened there was a small bump (say 4-7%) of CPU used by X each time the freeze happened. Total CPU time was low and it wasn’t ever showing “disk sleep”, so it didn’t seem like a swapping problem. Eventually it occurred to me to check the X logs: I looked in /var/log/Xorg.0.log this morning and found that each time the “freeze” happens, entries similar to this are logged:

   327.382] (II) config/udev: removing device Logitech USB-PS/2 Optical Mouse
   327.382] (II) event4  - Logitech USB-PS/2 Optical Mouse: device removed
   327.418] (II) UnloadModule: "libinput"
   327.932] (II) config/udev: Adding input device Logitech USB-PS/2 Optical Mouse (/dev/input/mouse0)
   327.932] (II) No input driver specified, ignoring this device.
   327.932] (II) This device may have been added with another device file.
   328.049] (II) config/udev: Adding input device Logitech USB-PS/2 Optical Mouse (/dev/input/event4)
   328.049] (**) Logitech USB-PS/2 Optical Mouse: Applying InputClass "evdev pointer catchall"
   328.049] (**) Logitech USB-PS/2 Optical Mouse: Applying InputClass "libinput pointer catchall"
   328.049] (II) Using input driver 'libinput' for 'Logitech USB-PS/2 Optical Mouse'
   328.049] (**) Logitech USB-PS/2 Optical Mouse: always reports core events
   328.049] (**) Option "Device" "/dev/input/event4"
   328.050] (**) Option "_source" "server/udev"
   328.110] (II) event4  - Logitech USB-PS/2 Optical Mouse: is tagged by udev as: Mouse
   328.111] (II) event4  - Logitech USB-PS/2 Optical Mouse: device set to 800 DPI
   328.111] (II) event4  - Logitech USB-PS/2 Optical Mouse: device is a pointer
   328.111] (II) event4  - Logitech USB-PS/2 Optical Mouse: device removed
   328.140] (**) Option "config_info" "udev:/sys/devices/pci0000:00/.../input/input20/event4"
   328.140] (II) XINPUT: Adding extended input device "Logitech USB-PS/2 Optical Mouse" (type: MOUSE, id 12)
   328.144] (**) Option "AccelerationScheme" "none"
   328.147] (**) Logitech USB-PS/2 Optical Mouse: (accel) selected scheme none/0
   328.147] (**) Logitech USB-PS/2 Optical Mouse: (accel) acceleration factor: 2.000
   328.147] (**) Logitech USB-PS/2 Optical Mouse: (accel) acceleration threshold: 4
   328.206] (II) event4  - Logitech USB-PS/2 Optical Mouse: is tagged by udev as: Mouse
   328.206] (II) event4  - Logitech USB-PS/2 Optical Mouse: device set to 800 DPI
   328.207] (II) event4  - Logitech USB-PS/2 Optical Mouse: device is a pointer

There are sometimes only 5-10 seconds between “freezes” whereas sometimes there are several minutes. I’ve noticed no issues with the keyboard and nothing odd with the display. These log messages don’t really indicate much to me, does anyone have any suggestions on what I can do to further troubleshoot this?

To me this looks like a damaged USB port or cable. At least a hardware issue.

Well, I’ve tried different ports now on both the back and front of my machine and they all exhibit the same behavior, so not the port. I’ll have to try it with my laptop and see if I get weird behavior there, although that obviously has of variables at play.