[CONJ-887] Current position is after the last row Created: 2021-06-08  Updated: 2021-07-02  Resolved: 2021-07-02

Status: Closed
Project: MariaDB Connector/J
Component/s: aurora
Affects Version/s: 2.6.2
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Björn Raupach Assignee: Diego Dupin
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

AWS Aurora MySQL 5.6



 Description   

Hi there,

not really a bug but this looks like the best place to ask and I am a bit lost.

I am regulary seeing a "Current position is after the last row" SQLException in my production logs. I have no idea why they happen and I am unable to reproduce the error on my local machine. In addition, this exception does not happen every time. Just a small fraction within thousands of other statements that do work.

Unfortunately reading the source code didn't help me much either. I know why the error happens, but I don't understand why this situation even occurs. rowPointer >= dataSize should never happen.

Here are the steps I do in production

  • connection.prepareStatement("SELECT * FROM Table WHERE Id = ? FOR UPDATE",
    ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)
  • Next I check the ResultSet (rs) returned from executeQuery
  • If rs.next() is true
  • I might do an rs.updateRow()
  • If rs.next() is false
  • rs.moveToInsertRow(), some rs.updateXZY and followed by rs.insertRow()

In summary I do a insert row if it doesn't exist otherwise I might update the row.

Any ideas how to narrow this one down?



 Comments   
Comment by Diego Dupin [ 2021-06-29 ]

Having the complete stackTrace would help narrowing issue at least

The only way i see to get this kind of error is moving during insert.
An example :

       rs.moveToInsertRow(); // moves cursor to the insert row
       rs.updateString(1, "AINSWORTH"); // updates the
          // first column of the insert row to be AINSWORTH
       rs.updateInt(2,35); // updates the second column to be 35
       rs.updateBoolean(3, true); // updates the third column to true
       rs.insertRow();
       rs.moveToCurrentRow();

moving cursor with methods like next, absolute, ... after moveToInsertRow(), but before insertRow() might result in that kind of state.

Comment by Björn Raupach [ 2021-06-30 ]

Hi Diego,

apologies. I don't think there is an issue with the driver. It looks like just some programming bug. There was no check wether or not rs.next() does actually return true. It was just assumed. Hence the error message.

Again, I am very sorry. Not a bug. Please close this issue.

Comment by Diego Dupin [ 2021-07-02 ]

better this way .
closing now

Generated at Thu Feb 08 03:19:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.