I have a problem running the command upsert in MongoDB when I try to connect 3 shards.
If I connect only one shard, I don't have problems.
The code I'm using is:
ConnectionString cs("mongodb://host:pass#server1:27017,server2:27017,server3:27017", ConnectionString::ConnectionType::SYNC);
DBClientBase *conn = cs.connect( mongo_erro );
BSONObjBuilder bojUpsert;
bojUpsert.append("teste","1234567890");
bojUpsert.append("valor",123);
conn->update("xxx.xxx", Query("{teste:\"1234567890\"}") , bojUpsert.obj() , mongo::UpdateOptions::UpdateOption_Upsert);
And the error I receive is:
**terminate called after throwing an instance of 'mongo::UserException'
what(): SyncClusterConnection::update upsert query needs _id**
I'm using Linux Mint, QT 4.8.6 + libmongo-client-dev 0.1.7-1
Related
We are getting deadlocks inside DMS at least 30% of the time or more on several of the larger sprocs which truncate and insert several million rows. However, there is only one query running, so I don't see how the deadlock can be my fault:
Msg 110802, Level 16, State 1, Line 1
110802;An internal DMS error occurred that caused this operation to fail. Details: Exception: Microsoft.SqlServer.DataWarehouse.DataMovement.Workers.DmsSqlNativeException, Message: SqlNativeBufferReader.Run, error in OdbcExecuteQuery: SqlState: 40001, NativeError: 1205, 'Error calling: SQLExecDirect(this->GetHstmt(), (SQLWCHAR *)statementText, SQL_NTS), SQL return code: -1 | SQL Error Info: SrvrMsgState: 71, SrvrSeverity: 13, Error <1>: ErrorMsg: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Transaction (Process ID 2265) was deadlocked on lock | generic waitable object resources with another process and has been chosen as the deadlock victim. Rerun the transaction. | Error calling: pReadConn->ExecuteQuery(statementText, bufferFormat) | state: FFFF, number: 7801, active connections: 120', Connection String: Driver={pdwodbc};APP=TypeC01-DmsNativeReader:DB3\mpdwsvc (13732)-ODBC;Trusted_Connection=yes;AutoTranslate=no;Server=\\.\pipe\DB.3-b6c0a7b26544\sql\query
And:
110802;An internal DMS error occurred that caused this operation to fail. Details: Exception: Microsoft.SqlServer.DataWarehouse.DataMovement.Workers.DmsSqlNativeException, Message: SqlNativeBufferReader.Run, error in OdbcExecuteQuery: SqlState: 40001, NativeError: 1205, 'Error calling: SQLExecDirect(this->GetHstmt(), (SQLWCHAR *)statementText, SQL_NTS), SQL return code: -1 | SQL Error Info: SrvrMsgState: 71, SrvrSeverity: 13, Error <1>: ErrorMsg: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Transaction (Process ID 804) was deadlocked on lock | generic waitable object resources with another process and has been chosen as the deadlock victim. Rerun the transaction. | Error calling: pReadConn->ExecuteQuery(statementText, bufferFormat) | state: FFFF, number: 8106, active connections: 240', Connection String: Driver={pdwodbc};APP=TypeC01-DmsNativeReader:DB38\mpdwsvc (14728)-ODBC;Trusted_Connection=yes;AutoTranslate=no;Server=\\.\pipe\DB.38-b6c0a7b26544\sql\query
Does this point at something obvious to check or fix? Or is an Azure support case the best road to a resolution?
update: support case 115111713384329 is open for this issue
update: our SQL DW got a new update March 4, 2016 which supposedly fixes this issue. (I can't reproduce it on demand so I can't say for sure.) If you run "select ##version" then
10.0.8224.5 or higher should have the fix. If you don't have the fix yet I would imagine opening a support case and requesting it or waiting a few weeks would get you the fix.
Creating an Azure support case would be best in this case. If you can share your stored procedure, that would help us root cause.
I am checking my SQL connection state as:
_ConnectionPtr m_pADOConnection;
// Connection is created and working fine...
// Now I disable network adapter (from Control panel)
if( (pApp->m_pConnection->GetState() == adStateOpen) )
{
// I got here every time....
}
The problem is I get every time adStateOpen even if connection is really not working!
If I try to execute a query or do anything it fails, mostly with
SMux Provider: Physical connection is not usable [xFFFFFFFF].
or
Error number: 80004005 = Unable to open a logical session
Is this value of State property reliable or I need to perform some other check top detect this state?
The state property does not become 0 (adStateClosed) when the connection is interrupted. So checking the state of the connection will always return 1 (adStateOpen) even after the connection is interrupted.
No there is no way to check immediately. The architecture of SQL servers don't allow for it.
I advise you to create an error handling.
It looks as though the only way to establish that the connection has been lost is to try to open it and handle the error.
I have established connection to a Siemens S7-300 PLC (simulated via PlcSIM) using the libnodave library. There are no issues connecting and writing data to the PLC. However, I am unable to change the status of the PLC from Start/Stop. I am attempting to use the following libnodave methods for such actions:
int daveStatus = daveStart(dc);
int daveStatus = daveStop(dc);
Both function calls return the same Error: 33794
nodave.c Cites the error as the following:
case 0x8402: return "CPU already in RUN or already in STOP ?";
The use of the daveStart() and daveStop() functions can be viewed in the example testS7online.c:
if(doStop) {
daveStop(dc);
}
if(doRun) {
daveStart(dc);
}
In the examples the start/stop functions are only called when MPI connections to the PLC are made. Does anyone know if the start/stop functions are supported for use with TCP connections? If so, any suggestions as to what may be causing my error?
I have just tried dc.start() and dc.stop() using libnodave 8.4 and NetToPlcSim tool. It worked perfectly. Possibly you don't use NetToPlcSim tool that makes connection to PLCSim via TCP/IP (that is 127.0.0.1 port 102 obviously) hence dc can't even connect. So if your lines don't work, then u must be doing something wrong.
I'm running a django-celery application on Ubuntu-12.04.
When I run a celery task from my web interface, I get the following error, taken form postgresql-9.3 logfile (maximum level of log):
2013-11-12 13:57:01 GMT tss_usr 8113 LOG: could not receive data from client: Connection reset by peer
tss_usr is the postgresql user of the django application database and (in this example) 8113 is the pid of the process who killed the connection, I guess.
Have you got any idea on why this happens or at least how to debug this issue?
To make things work again I need to restart postgresql which is extremely uncomfortable.
I know this is an older post, but I just found it because I had the same error today in my postgres logs. I narrowed it down to a PDO select statement. I'm using Zend Framework 1.10.3 on Ubuntu Precise.
The following pdo statement generated an error if $opinion is a long text string. The column opinion is type Text in my postgres table. The query succeeds if $opinion is under a certain number of characters. 1000 characters works fine. 2000 characters fails with "could not receive data from client: Connection reset by peer".
$select = $this->db->select()
->from( 'datauserstopics' )
->where("opinion = ?",trim($opinion))
->where("datatopicsid = ?",trim($tid))
->where("datausersid= ?",$datausersid);
$stmt = $this->db->query($select);
I circumvented the problem by using:
->where("substr(opinion,1,100) = ?",trim(substr($opinion,1,100)))
This is not a perfect solution, but for my purposes, the select statement using substr() suffices.
Note that I have no problem inserting long strings into the same table/column. The disconnect problem only appears for me on the PDO select with relatively long text strings.
I'm getting it in 2017 with 9.4, I have no text fields, don't know what a PDO is. My select statement is about 50 bytes long, I'm trying to fetch an int4 and a double precision. I suspect the error message can mean multiple things.
I've since found https://dba.stackexchange.com/questions/142350/postgres-could-not-receive-data-from-client-connection-reset-by-peer which indicates it could be a problem with the client configuration. My client is libpg and PQconnectdb() is giving me a CONNECTION_OK return. It works at least partly.
For me, restarting the hypervisor where both the Postgres and the application using it helped. I've seen stack traces in dmesg before, though.
I connected MSSQL (on windows) via odbc on linux redhat 64bit.
Below is odbc and freetds configuration files.
freetds.conf:
[FreeTDS]
host=172.21.32.20
port=1433
tds version=7.2
client charset = GB2312
odbcinst.ini:
[TDS]
Description = TDS
Driver = /usr/local/lib/libtdsodbc.so
Trace = Yes
TraceFile=/tmp/odbcinst.log
UsageCount = 1
odbc.ini:
[SQLSERVER]
Driver = TDS
Description = sql server dsn
Trace = NO
Server = 172.21.32.20
Database = Live
Port = 1433
TDS_Version = 7.2
TraceFile=/tmp/sqlserver.log
Snippets:
QString f3ErpDsn = QString::fromLocal8Bit("Driver={SQLSERVER};server=172.21.32.20;database=Live;uid=inp;pwd=inp;");
QSqlDatabase f3ErpDb= QSqlDatabase::addDatabase("QODBC");
f3ErpDb.setDatabaseName(f3ErpDsn);
// f3ErpDb.setDatabaseName("SQLSERVER");
f3ErpDb.setUserName("inp");
f3ErpDb.setPassword("inp");
QString sqlCmdStr = "select * from dbo.Table_Drilling_Data01 where status=1";
if ( ! f3ErpDb.open() )
{
qDebug() << f3ErpDb.lastError().text();
return 1;
}
QSqlTableModel model;
model.setTable("dbo.Table_Drilling_Data01");
model.setFilter("status=3");
model.select();
qDebug() << model.lastError().text();
Error messages:
f3ErpDb.setDatabaseName(f3ErpDsn);
If setDatabaseName is f3ErpDsn error message is:
"QODBC3: Unable to connect", "[unixODBC][Driver Manager]Data source name not found, and no default driver specified")
I had defined SQLSERVER in odbc.ini. Why it can not find it?
But if I changed f3ErpDb.setDatabaseName("SQLSERVER");, error message is:
"[FreeTDS][SQL Server]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (""): Data type 0x00 is unknown. QODBC3: Unable to execute statement"
It makes me confounded, could anybody help me?
I'm not sure what QSqlDatabase is. But it seems that you have improper SQL connection string.
Try something like this:
UID=inp;PWD=inp;DSN=SQLSERVER;database=Live;SERVER=AMIN\SQLEXPRESS;charset=UTF-8
DSN=SQLSERVER because SQLSERVER is the only DSN which defined in your odbc.ini
SERVER=AMIN\SQLEXPRESS - try Windows name of SQL Server, not host's IP address (I'm not sure that IP is not allowed here, but Windows name is 100% working)
I had the same problem and I solve it when I changed TDS protocol to 8.0, it was at 7.0 before. I've used freetds, unixodbc, via Qt to connect to MSSQL database.