Menu

#1473 SELECT...FOR UPDATE locking unexpected behaviour

version 2.4.x
closed-works-for-me
None
1
2019-06-04
2017-03-05
No

There is a thread about this that has some background info here:
https://sourceforge.net/p/hsqldb/discussion/73674/thread/4bdce697/

Basically, I'm trying to use SELECT...FOR UPDATE to coordinate access to a shared pool of tasks where each task is represented as a row. The goal is to ensure that each task is picked up by one thread only. Each thread queries for a "pending" task and then, while holding the update lock, changes that task from "pending" to "processing" so that no other "pending" query will return that task.

This method has the expected behaviour on other DBs I've tried but not HSql.

I've attached a test program showing the issue. You can just import it into Eclipse. I tried this program against a SAP HANA database and it works in the expected way.

1 Attachments

Discussion

  • Fred Toussi

    Fred Toussi - 2017-04-11
    • status: open --> closed-works-for-me
    • assigned_to: Fred Toussi
    • Priority: 5 --> 1
     
  • Fred Toussi

    Fred Toussi - 2017-04-11

    The issue is with the query. Use of " LIMIT 1 " in the query makes it non-updatable (this follows the SQL standard). After removing the LIMIT the test case runs successfully and prints "Complete!"

     
    • Scott Cameron

      Scott Cameron - 2017-04-13

      I added a reply to the discussion thread making the argument that this should potentially be supported despite the letter of the SQL standard. Any chance this could be reconsidered?

      https://sourceforge.net/p/hsqldb/discussion/73674/thread/4bdce697/#419e/55c9

       

Log in to post a comment.

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.