Giter Site home page Giter Site logo

Comments (4)

paulcwarren avatar paulcwarren commented on May 13, 2024

Thanks @inngvar. That isn't much of an embarrassing bug, is it?!?

I wonder how that was missed by our integration tests. Anyways, will fix.

from spring-content.

paulcwarren avatar paulcwarren commented on May 13, 2024

I looked at this a bit today. In fact it is working as designed; i.e. although a little weird the SQL is correct. When it comes to blob streaming the devil is in the detail as this blog post explains. On the surface JDBC provides several ways to get an input stream from a result set but when you go look at how they are implemented you often find they read the whole BLOB into memory.

This, in fact, is what MySQL does unless you use a feature called "locator emulation". With "locator emulation" turned on then the getBlob() jdbc api will use a different implementation that streams the content properly (i.e. in reasonable size chunks) through the memory space of the JVM running the mysql connector client. Without this the risk of OOMs are much greater and increase with the size of the content being stored.

To use "location emulation" you have to do a couple of things.

  1. You have to specify emulateLocators=true on the end of the jdbc connection string URL
  2. The SQL you use to fetch the result set have to specify the name of the column that stores the blob/"locator". This is because behind the scenes when you call getBlob and then getBinaryStream on that blob object it creates and executes its own queries fetching chunks of the blob at a time and it uses the column name encoded in the sql statement to help create these queries. Presumably because otherwise it wouldnt know which column the blob was stored in.

So, it is not clear if this is working for you, or not. If it isnt then I suspect you might not have emulateLocators=true on the end of your JDBC connection string. Admittedly, this isn't in our docs. So perhaps that is the bug here?

Anyways, let me know.

from spring-content.

inngvar avatar inngvar commented on May 13, 2024

Thank you, solution you suggest ( add emulateLocators=true) works fine.
And also thanks for the detailed description of the problem. As I thought, not everything is as obvious as it seemed.

from spring-content.

paulcwarren avatar paulcwarren commented on May 13, 2024

No problem. I'm going to close this as I think we are resolved. However, feel free to re-open or raise another issue if you find anything else.

from spring-content.

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.