Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what is serverStatus? #1089

Closed
iyjian opened this issue May 12, 2015 · 13 comments
Closed

what is serverStatus? #1089

iyjian opened this issue May 12, 2015 · 13 comments
Assignees
Labels

Comments

@iyjian
Copy link

iyjian commented May 12, 2015

i issued a insert sql into mysql using node-mysql

conn.query('insert into articles (memberID,title,date) values (?,?,?)',
[memberID,title,date],function(error,result){
                        conn.release();
                        if(error){
                            cb('insertDataQueryError',null);
                        }else{
                            console.log(JSON.stringify(result));
                            cb(null,result.insertId);
                        }
                    });

the articles table is a table with a auto incremental id

i can get the insertId correctly, but i cannot find the data in database.
then i print the result out:

{"fieldCount":0,"affectedRows":1,"insertId":292,"serverStatus":3,"warningCount":0,"message":"","protocol41":true,"changedRows":0} 

i found there is a serverStatus column,and when the insert act correctly,the column is 2.

could you give some advise why the data can not insert correctly?

@dougwilson dougwilson self-assigned this May 12, 2015
@dougwilson
Copy link
Member

The serverStatus is what comes back from your MySQL server. The values are documented at http://dev.mysql.com/doc/internals/en/status-flags.html

As for why your data is not inserted, I really have no idea, because there is not enough information. Your serverStatus = 3 means you have both SERVER_STATUS_AUTOCOMMIT and SERVER_STATUS_IN_TRANS, so perhaps you were missing a COMMIT query to end your transaction you started?

@iyjian
Copy link
Author

iyjian commented May 13, 2015

i don't perform a commit after insert operation,but i thought the node-mysql perform auto-commit after the insertion,and this strange issue only appear after server repeat call(it insert correctly at the first beginning calls)

@dougwilson
Copy link
Member

node-mysql does nothing for you--it just sends the queries as you ask to the MySQL server.

@dougwilson
Copy link
Member

But in the end, without full code and schema I can use to reproduce, it's hard to really provide any help. The information given so far only goes so far, I'm sorry.

@iyjian
Copy link
Author

iyjian commented May 13, 2015

ok, i would post the full code in minute

@iyjian
Copy link
Author

iyjian commented May 13, 2015

@iyjian
Copy link
Author

iyjian commented May 13, 2015

the refined code as above , many thanks if you can give it a look

@dougwilson
Copy link
Member

I gave it a look, but nothing looks wrong. Is that the only query you ever make? I ask because based on your statement that it works when serverStatus is 2, but doesn't when 3, the different between them is because somewhere in your code, you are starting a transaction but not ending it.

@iyjian
Copy link
Author

iyjian commented May 13, 2015

yes , i perform a serval call befroe this operation , i can only using mocha to reproduce this error. when i call the service in browser or i my application, it is normal.

i would refined the mocha test script and tell you the result, i would waste your time if post the full script.

thanks in advance .

@dougwilson
Copy link
Member

No problem, but I assume that when you try in the browser, all you're doing is simply calling the one route? Then in your mocha you are probably calling a whole bunch of things and it just takes one thing to be wrong to get the hang up, most likely. Also, calling .release() doesn't do anything to your connection, just as a FYI. There is also the possibility that there is some race condition in the tests? I'm not sure :/

@araker
Copy link

araker commented Oct 26, 2017

Sorry to bump an old topic, but the url of the server status flags documentation has become outdated. The new url is https://dev.mysql.com/doc/dev/mysql-server/latest/PAGE_PROTOCOL.html, but I can't find the serverStatus in there. Can someone point me in the right direction?

@ruiquelhas
Copy link
Contributor

@araker
Copy link

araker commented Oct 27, 2017

Thanks for the assist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants