dolt: CJException: 3878257648 out of range for int

Setup

dolt as database created databse restdb added user restadmin used source https://github.com/springframeworkguru/spring-6-rest-mvc/tree/77-flyway-intit-script run application with profile: localmysql application-localmysql.properties

no tables needed in restdb for this setup to run.

MySQL

no error

Error

com.mysql.cj.exceptions.CJException: 3878257648 out of range for int

dolt log with log level debug:

DEBU[42019] preparing query                               paramsCount=9 query="INSERT INTO `restdb`.`flyway_schema_history` (`installed_rank`, `version`, `description`, `type`, `script`, `checksum`, `installed_by`, `execution_time`, `success`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" statementId=13
DEBU[42771] Starting query                                connectTime="2024-06-28 13:58:27.503963 +0200 CEST m=+42015.283576001" connectionDb=restdb connectionID=52 query="INSERT INTO `restdb`.`flyway_schema_history` (`installed_rank`, `version`, `description`, `type`, `script`, `checksum`, `installed_by`, `execution_time`, `success`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"

asSql():

INSERT INTO `restdb`.`flyway_schema_history` 
(`installed_rank`, `version`, `description`, `type`, `script`, `checksum`, `installed_by`, `execution_time`, `success`) 
VALUES 
(1, '1', 'init-mysql-database', 'SQL', 'V1__init-mysql-database.sql', -416709648, 'restadmin', 32, 1)

query command:

17 0d 00 00 00 00 01 00     . . . . . . . .
00 00 00 00 01 03 00 fd     . . . . . . . .
00 fd 00 fd 00 fd 00 03     . . . . . . . .
00 fd 00 03 00 01 00 01     . . . . . . . .
00 00 00 01 31 13 69 6e     . . . . 1 . i n
69 74 2d 6d 79 73 71 6c     i t - m y s q l
2d 64 61 74 61 62 61 73     - d a t a b a s
65 03 53 51 4c 1b 56 31     e . S Q L . V 1
5f 5f 69 6e 69 74 2d 6d     _ _ i n i t - m
79 73 71 6c 2d 64 61 74     y s q l - d a t
61 62 61 73 65 2e 73 71     a b a s e . s q
6c f0 83 29 e7 09 72 65     l . . ) . . r e
73 74 61 64 6d 69 6e 20     s t a d m i n  
00 00 00 01                 . . . .

the command creating the error info is running in com.mysql.cj.ServerPreparedQuery.java Line 278:

NativePacketPayload resultPacket = this.session.getProtocol().sendCommand(packet, false, 0);

result packet:

ff 51 04 23 48 59 30 30     . Q . # H Y 0 0
30 33 38 37 38 32 35 37     0 3 8 7 8 2 5 7
36 34 38 20 6f 75 74 20     6 4 8   o u t  
6f 66 20 72 61 6e 67 65     o f   r a n g e
20 66 6f 72 20 69 6e 74       f o r   i n t

PS: I missing this error in the dolt log

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

Thx a lot - it can confirm it is fixed with 1.42.7

The fix for this issue has been released in Dolt v1.42.7.

Thanks for taking the time to report this one and for all the help getting us a repro! 🙏 This was a really great find.

I’ll go ahead and resolve this, but let us know if you hit any other issues and we’ll be happy to help!

I’ve got a fix in place for this – just doing some more digging to see if other places are affected and writing some tests. I’ll get a PR out today for it.

The issue is in our fork of Vitess, which is parsing the values from the MySQL wire protocol to bind to the prepared statement. It wasn’t casting the parsed value to an int32 before it packaged it up into a larger numeric type, so the sign bit didn’t get interpreted correctly.

Thanks @muescha! I’ve got a repro now 😎

I was able to repro the error using the command above, and after looking at the packets on the wire, I see that the Dolt sql-server is returning the 3075161371 out of range for int error. I was also able to simplify the repro with just preparing a statement that inserts -1219805925 into an int field using a prepared statement. (I also learned that the MySQL JDBC driver won’t use real, server-side prepared statements unless you set the useServerPrepStmts=true connection property 🤷🏻‍♂️)

Now that I’ve got a repro, I’m going to dig in and see what Dolt is doing differently than MySQL. I’ll keep you updated with what I find.

Hi @muescha, thank you for the error report! 🙏 Looks like we’ve got enough to repro here. We’ll work on a repro today and see what’s going on. My first guess is that the we aren’t sending a response metadata bit that the MySQL Connector/J library needs to treat the int value as unsigned. We’ll keep you updated with what we find.