SQL database user_session table PRI key overflow causing API auth failure

Community Support for Booked Scheduler
Post Reply
aarong
Posts: 1
Joined: Thu Jan 14, 2021 2:31 pm

SQL database user_session table PRI key overflow causing API auth failure

Post by aarong »

I am having an issue with the booked API, trying to POST to /Web/Services/index.php/Authentication/Authenticate.

After a little digging, it turns out the user_session_id(auto-increment/mediumint(8) unsigned) in the user_session sql table has maxed out at 16777215.
This is causing the SQL INSERT query to fail, as it can only create a duplicate user_session_id value.

Anyone have a clue how to get around this issue or if this is a bug? We have some automated process that uses the API very often to authenticate, and after a while even if we reset the user_session_id, we would most likely hit this issue again.

Thanks. Here is the database table info for more context:

Code: Select all

mysql> describe user_session;
Current database: bookedscheduler

+--------------------+-----------------------+------+-----+---------+----------------+
| Field              | Type                  | Null | Key | Default | Extra          |
+--------------------+-----------------------+------+-----+---------+----------------+
| user_session_id    | mediumint(8) unsigned | NO   | PRI | NULL    | auto_increment |
| user_id            | mediumint(8) unsigned | NO   | MUL | NULL    |                |
| last_modified      | datetime              | NO   |     | NULL    |                |
| session_token      | varchar(50)           | NO   | MUL | NULL    |                |
| user_session_value | text                  | NO   |     | NULL    |                |
+--------------------+-----------------------+------+-----+---------+----------------+
5 rows in set (0.03 sec)

User avatar
TechCoder
Posts: 68
Joined: Mon Aug 10, 2020 12:54 pm
Contact:

Re: SQL database user_session table PRI key overflow causing API auth failure

Post by TechCoder »

Seems to me that you could set that to INT instead of mediumint.....

Table 11.1 Required Storage and Range for Integer Types Supported by MySQL
Type Storage (Bytes) Maximum Value Unsigned
SMALLINT 2 65535
MEDIUMINT 3 16777215
INT 4 4294967295
BIGINT 8 264-1

I don't see any issue with doing that (though it is totally an opinion, untested, disclaimer, disclaimer, etc.!!!!) - other than if you do any upgrades to Booked you may have to set the table again (not likely, but something to keep in mind!)
Apps-n-Add-Ons.com is independently owned and operated and provides clients worldwide with Plugins for Booked Scheduler to solve common needs.
Custom software solutions, paid help, Booked Hosting and more..... Apps-n-Add-Ons.com

Post Reply