Skip to content

Commit

Permalink
added shared key for replication of replace statement to fix pre_comm…
Browse files Browse the repository at this point in the history
…it error on replication replace from multiple master nodes; fixed log of search for reqests with delete and update
  • Loading branch information
tomatolog committed May 17, 2023
1 parent 102ac60 commit 77ccd8f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/accumulator.h
Expand Up @@ -133,6 +133,7 @@ class RtAccum_t
int GetPackedLen() const;

bool SetupDocstore ( const RtIndex_i & tIndex, CSphString & sError );
bool IsReplace () const { return m_bReplace; }

private:
bool m_bReplace = false; ///< insert or replace mode (affects CleanupDuplicates() behavior)
Expand Down
5 changes: 4 additions & 1 deletion src/searchd.cpp
Expand Up @@ -3051,7 +3051,10 @@ static void FormatIndexHints ( const CSphQuery & tQuery, StringBuilder_c & tBuf

static void LogQueryJson ( const CSphQuery & q, StringBuilder_c & tBuf )
{
tBuf << " /*" << q.m_sRawQuery << " */";
if ( q.m_sRawQuery.IsEmpty() )
tBuf << " /*" << "{\"index\":\"" << q.m_sIndexes << "\"}*/ /*" << q.m_sQuery << " */";
else
tBuf << " /*" << q.m_sRawQuery << " */";
}


Expand Down
1 change: 1 addition & 0 deletions src/searchdhttp.cpp
Expand Up @@ -1803,6 +1803,7 @@ class HttpHandler_JsonUpdate_c : public HttpHandler_c, HttpJsonUpdateTraits_c
TRACE_CONN ( "conn", "HttpHandler_JsonUpdate_c::Process" );
SqlStmt_t tStmt;
tStmt.m_bJson = true;
tStmt.m_tQuery.m_eQueryType = QUERY_JSON;
tStmt.m_sEndpoint = HttpEndpointToStr ( SPH_HTTP_ENDPOINT_JSON_UPDATE );

DocID_t tDocId = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/searchdreplication.cpp
Expand Up @@ -1207,7 +1207,7 @@ DEFINE_RENDER ( RPLRep_t )


// replicate serialized data into cluster and call commit monitor along
static bool Replicate ( int iKeysCount, const wsrep_key_t * pKeys, const wsrep_buf_t & tQueries, wsrep_t * pProvider, CommitMonitor_c & tMonitor, bool bUpdate, CSphString & sError )
static bool Replicate ( int iKeysCount, const wsrep_key_t * pKeys, const wsrep_buf_t & tQueries, wsrep_t * pProvider, CommitMonitor_c & tMonitor, bool bUpdate, bool bSharedKeys, CSphString & sError )
{
TRACE_CONN ( "conn", "Replicate" );
assert ( pProvider );
Expand All @@ -1224,7 +1224,7 @@ static bool Replicate ( int iKeysCount, const wsrep_key_t * pKeys, const wsrep_b
tHnd.trx_id = iConnId;
tHnd.opaque = nullptr;

wsrep_status_t tRes = pProvider->append_key ( pProvider, &tHnd, pKeys, iKeysCount, WSREP_KEY_EXCLUSIVE, false );
wsrep_status_t tRes = pProvider->append_key ( pProvider, &tHnd, pKeys, iKeysCount, ( bSharedKeys ? WSREP_KEY_SHARED : WSREP_KEY_EXCLUSIVE ), false );
bool bOk = CheckResult ( tRes, tLogMeta, "append_key", sError );

if ( bOk )
Expand Down Expand Up @@ -1977,7 +1977,7 @@ static bool HandleCmdReplicate ( RtAccum_t & tAcc, CSphString & sError, int * pD
END_CONN ( "conn" );

if ( !bTOI )
return Replicate ( iKeysCount, dKeys.Begin(), tQueries, pCluster->m_pProvider, tMonitor, bUpdate, sError );
return Replicate ( iKeysCount, dKeys.Begin(), tQueries, pCluster->m_pProvider, tMonitor, bUpdate, tAcc.IsReplace(), sError );
else
return ReplicateTOI ( iKeysCount, dKeys.Begin(), tQueries, pCluster->m_pProvider, tMonitor, pDesc, sError );
}
Expand Down

0 comments on commit 77ccd8f

Please sign in to comment.