Giter Club home page Giter Club logo

Comments (12)

jdmcd avatar jdmcd commented on May 14, 2024 3

+1 for this!

from fluent-kit.

gwynne avatar gwynne commented on May 14, 2024 2

The most common issues when trying to do this with Fluent are:

  1. For MySQL users, SET TRANSACTION ISOLATION LEVEL can not be issued through the full query interface that FluentKit and SQLKit use, you have to drop down to MySQLKit-level API to use the simpleQuery command.
  2. More globally, the isolation level setting is per-connection, and unless explicitly told not to, Fluent can send any given query on any connection it has to the database on the same event loop, including opening a new one if all existing connections are considered busy at the time. The only ways around this are to either use the Database.withConnection(_:) API to request a specific connection to issue the isolation level query on and then call Database.transaction(_:) on that connection, or to set maxConnectionsPerEventLoop to 1 so there will only ever be one connection on any given event loop (which is almost certainly not what you want).

The API I have in mind for providing transaction isolation level support will take care of both of these problems transparently.

from fluent-kit.

tanner0101 avatar tanner0101 commented on May 14, 2024

Is there any way to set the isolation level for a given transaction without setting it globally? Given that connections are re-used in Fluent, I don't think it would be a good idea to set it globally.

from fluent-kit.

calebkleveter avatar calebkleveter commented on May 14, 2024

I tired to do that. In theory you should be able to to set it without the GLOBAL keyword:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

But for some reason that didn't seem to work, as though I had never set the isolation level at all. This might need more research.

from fluent-kit.

jdmcd avatar jdmcd commented on May 14, 2024

@0xTim what do you think the effort level would be like to get this added to Fluent? Right now we have a case where a nightly long-running transaction kicked off by a client is blocking access to the site because it's locking up a bunch of tables that get called frequently. We (Transeo) would be happy to contribute dev effort towards this if we got pointed in the right direction.

from fluent-kit.

0xTim avatar 0xTim commented on May 14, 2024

Honestly I'm not sure, it's outside my SQL knowledge. @gwynne any idea? From the looks of @calebkleveter 's implementation it should be fairly straight forward, we'd just need to add it to MySQL and Postgres as they'll be the only ones that support it I think

from fluent-kit.

0xTim avatar 0xTim commented on May 14, 2024

bump @gwynne

from fluent-kit.

gwynne avatar gwynne commented on May 14, 2024

Sorry for the delay in replying! To answer @jdmcd's question: Getting this added at the FluentKit/SQLKit layers is actually pretty straightforward, just need an extra property in SQLDialect and to update the drivers that do provide isolation level support, which is just MySQL and Postgres (arguably SQLite's BEGIN EXCLUSIVE TRANSACTION can be considered an isolation level as well, but that's probably overdoing it since it'd require a whole separate set of syntax support, as with the mess that is enum handling). I could probably do the work in an hour or two if I put my mind to it.

from fluent-kit.

ptrkstr avatar ptrkstr commented on May 14, 2024

@gwynne did you happen to have any update on this?
It's a feature that I'd find very useful.

from fluent-kit.

ptrkstr avatar ptrkstr commented on May 14, 2024

I tired to do that. In theory you should be able to to set it without the GLOBAL keyword:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

But for some reason that didn't seem to work, as though I had never set the isolation level at all. This might need more research.

@calebkleveter did you initiate the transaction first?
According to this, if you don't do that, the isolation level won't be considered.

from fluent-kit.

ptrkstr avatar ptrkstr commented on May 14, 2024

Thanks for continuing to look into it @gwynne. 🙏🙏🙏🙏🙏

from fluent-kit.

anonymouz4 avatar anonymouz4 commented on May 14, 2024

@gwynne any update on this?

from fluent-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.