question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cache and procedure

See original GitHub issue

Dear developers i am use mysql2 lib with PoolConnection on ExpressJS. When I make a two request (changing the parameters of the request), I get old (cached) data sometimes (reloading the page). Is it somehow connected with Lru cached, but it is impossible to disable it through the connection parameters or it bug?

in docunetation say: // If you execute same statement again, it will be picked from a LRU cache // which will save query preparation time and give better performance but i use Procedure and PoolQuery . Patching my CALL procedure added Math.Random but it had no effect

my source code

const mysql = require('mysql2');
const mysqlpool = mysql.createPool({
    host: 'localhost',
    user: 'root',
    database: 'base_test',
    waitForConnections: true,
    connectionLimit: 10,
    queueLimit: 0,
    multipleStatements: false,
    //caching: true
});

module.exports.getQuery = function (str,brand,resout) {
    let rnd = Math.random();
    let sqlProcedure = 'CALL alfaquery_v2(?,?);';
    mysqlpool.query(
        sqlProcedure,[str,rnd],
        function(err, rows) {
            if (err) {
                console.log(err);
                resout.send([]);
            }
            console.log(rows[0]);
            resout.send(rows[0]);
        });
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
outrankercommented, Mar 7, 2021

I solved the issue. The culprit was the transactions! I think there is a bug with transactions. I replaced all of the transactions with regular queries and now everything is working fine.

0reactions
yo-wancommented, Sep 22, 2022

I hit the same case today. Disabling transactions does the job, but it’s not an option for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Procedure cache
Procedure cache. Adaptive Server maintains an MRU/LRU (most recently used/least recently used) chain of stored procedure query plans.
Read more >
Understanding SQL Server query plan cache - SQLShack
Every query requires a query plan before it is actually executed. This query plan is stored in SQL Server query plan cache.
Read more >
How to Cache Stored Procedure Results - Brent Ozar Unlimited
This outright-truncation technique is less efficient for refreshing the cache, but it minimizes the locking required by deletes. In a caching ...
Read more >
Cache a Procedure - TechDocs - Broadcom Inc.
You can create, display, and delete cache entries by using the PCACHE and CPROC commands. A cached copy of a procedure is also...
Read more >
Procedure Cache - SAP Help Portal
SAP ASE maintains an MRU/LRU (most recently used/least recently used) chain of stored procedure query plans. As users execute stored procedures, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found