Skip to content
Permalink
Browse files
fixed #256 #263 invalid query cache entries for RT index; added regre…
…ssions to test 354
  • Loading branch information
tomatolog committed Apr 19, 2018
1 parent 1dcb548 commit 355b11629174813abd9cd5bf2233be0783f77745
Showing with 95 additions and 0 deletions.
  1. +5 −0 src/sphinxrt.cpp
  2. +1 −0 test/test_354/model.bin
  3. +89 −0 test/test_354/test.xml
@@ -7216,6 +7216,11 @@ bool RtIndex_t::MultiQuery ( const CSphQuery * pQuery, CSphQueryResult * pResult
CSphScopedPtr<ISphRanker> pRanker ( nullptr );
CSphScopedPayload tPayloads;

// FIXME!!! add proper
// - qcache invalidation after INSERT \ DELETE \ UPDATE and for plain index afte UPDATE #256
// - qcache duplicates removal from killed document at segment #263
tCtx.m_bSkipQCache = true;

// no need to create ranker, etc if there's no query
if ( !pQueryParser->IsFullscan(*pQuery) )
{
@@ -0,0 +1 @@
a:1:{i:0;a:49:{i:0;a:2:{s:8:"sphinxql";s:31:"SET GLOBAL qcache_thresh_msec=0";s:14:"total_affected";i:0;}i:1;a:2:{s:8:"sphinxql";s:36:"SET GLOBAL qcache_max_bytes=16777216";s:14:"total_affected";i:0;}i:2;a:2:{s:8:"sphinxql";s:27:"SET GLOBAL qcache_ttl_sec=3";s:14:"total_affected";i:0;}i:3;a:2:{s:8:"sphinxql";s:55:"INSERT INTO rt (id,gid,title) VALUES (1,111,'test one')";s:14:"total_affected";i:1;}i:4;a:2:{s:8:"sphinxql";s:55:"INSERT INTO rt (id,gid,title) VALUES (2,111,'test two')";s:14:"total_affected";i:1;}i:5;a:2:{s:8:"sphinxql";s:57:"INSERT INTO rt (id,gid,title) VALUES (3,111,'test three')";s:14:"total_affected";i:1;}i:6;a:2:{s:8:"sphinxql";s:167:"INSERT INTO rt (id,gid,title) VALUES (100,111,'no three'), (101,111,'no three'), (102,111,'no three'), (103,111,'no three'), (104,111,'no three'), (105,111,'no three')";s:14:"total_affected";i:6;}i:7;a:2:{s:8:"sphinxql";s:145:"INSERT INTO rt (id,gid,title) VALUES (200,111,'no three'), (201,111,'no three'), (202,111,'no three'), (203,111,'no three'), (204,111,'no three')";s:14:"total_affected";i:5;}i:8;a:2:{s:8:"sphinxql";s:55:"INSERT INTO rt (id,gid,title) VALUES (4,111,'no three')";s:14:"total_affected";i:1;}i:9;a:2:{s:8:"sphinxql";s:55:"INSERT INTO rt (id,gid,title) VALUES (5,111,'no three')";s:14:"total_affected";i:1;}i:10;a:2:{s:8:"sphinxql";s:55:"INSERT INTO rt (id,gid,title) VALUES (6,111,'no three')";s:14:"total_affected";i:1;}i:11;a:2:{s:8:"sphinxql";s:55:"INSERT INTO rt (id,gid,title) VALUES (7,111,'no three')";s:14:"total_affected";i:1;}i:12;a:2:{s:8:"sphinxql";s:55:"INSERT INTO rt (id,gid,title) VALUES (8,111,'no three')";s:14:"total_affected";i:1;}i:13;a:2:{s:8:"sphinxql";s:55:"INSERT INTO rt (id,gid,title) VALUES (9,111,'no three')";s:14:"total_affected";i:1;}i:14;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (10,111,'no three')";s:14:"total_affected";i:1;}i:15;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (11,111,'no three')";s:14:"total_affected";i:1;}i:16;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (12,111,'no three')";s:14:"total_affected";i:1;}i:17;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (13,111,'no three')";s:14:"total_affected";i:1;}i:18;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (14,111,'no three')";s:14:"total_affected";i:1;}i:19;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (15,111,'no three')";s:14:"total_affected";i:1;}i:20;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (16,111,'no three')";s:14:"total_affected";i:1;}i:21;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (17,111,'no three')";s:14:"total_affected";i:1;}i:22;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (18,111,'no three')";s:14:"total_affected";i:1;}i:23;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (19,111,'no three')";s:14:"total_affected";i:1;}i:24;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (20,111,'no three')";s:14:"total_affected";i:1;}i:25;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (21,111,'no three')";s:14:"total_affected";i:1;}i:26;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (22,111,'no three')";s:14:"total_affected";i:1;}i:27;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (23,111,'no three')";s:14:"total_affected";i:1;}i:28;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (24,111,'no three')";s:14:"total_affected";i:1;}i:29;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (25,111,'no three')";s:14:"total_affected";i:1;}i:30;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (26,111,'no three')";s:14:"total_affected";i:1;}i:31;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (27,111,'no three')";s:14:"total_affected";i:1;}i:32;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (28,111,'no three')";s:14:"total_affected";i:1;}i:33;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (29,111,'no three')";s:14:"total_affected";i:1;}i:34;a:2:{s:8:"sphinxql";s:56:"INSERT INTO rt (id,gid,title) VALUES (30,111,'no three')";s:14:"total_affected";i:1;}i:35;a:3:{s:8:"sphinxql";s:45:"SELECT *,WEIGHT() FROM rt WHERE MATCH('test')";s:10:"total_rows";i:3;s:4:"rows";a:3:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1655";}i:1;a:3:{s:2:"id";s:1:"2";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1655";}i:2;a:3:{s:2:"id";s:1:"3";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1655";}}}i:36;a:2:{s:8:"sphinxql";s:25:"DELETE FROM rt where id=2";s:14:"total_affected";i:1;}i:37;a:3:{s:8:"sphinxql";s:45:"SELECT *,WEIGHT() FROM rt WHERE MATCH('test')";s:10:"total_rows";i:2;s:4:"rows";a:2:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1655";}i:1;a:3:{s:2:"id";s:1:"3";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1655";}}}i:38;a:2:{s:8:"sphinxql";s:55:"INSERT INTO rt (id,gid,title) VALUES (2,111,'test two')";s:14:"total_affected";i:1;}i:39;a:3:{s:8:"sphinxql";s:45:"SELECT *,WEIGHT() FROM rt WHERE MATCH('test')";s:10:"total_rows";i:3;s:4:"rows";a:3:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1636";}i:1;a:3:{s:2:"id";s:1:"2";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1636";}i:2;a:3:{s:2:"id";s:1:"3";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1636";}}}i:40;a:2:{s:8:"sphinxql";s:58:"REPLACE INTO rt (id,gid,title) VALUES (3,222,'test three')";s:14:"total_affected";i:1;}i:41;a:3:{s:8:"sphinxql";s:45:"SELECT *,WEIGHT() FROM rt WHERE MATCH('test')";s:10:"total_rows";i:3;s:4:"rows";a:3:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1621";}i:1;a:3:{s:2:"id";s:1:"2";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1621";}i:2;a:3:{s:2:"id";s:1:"3";s:3:"gid";s:3:"222";s:8:"weight()";s:4:"1621";}}}i:42;a:2:{s:8:"sphinxql";s:29:"SET GLOBAL qcache_max_bytes=0";s:14:"total_affected";i:0;}i:43;a:2:{s:8:"sphinxql";s:36:"SET GLOBAL qcache_max_bytes=16777216";s:14:"total_affected";i:0;}i:44;a:3:{s:8:"sphinxql";s:45:"SELECT *,WEIGHT() FROM rt WHERE MATCH('test')";s:10:"total_rows";i:3;s:4:"rows";a:3:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1621";}i:1;a:3:{s:2:"id";s:1:"2";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1621";}i:2;a:3:{s:2:"id";s:1:"3";s:3:"gid";s:3:"222";s:8:"weight()";s:4:"1621";}}}i:45;a:2:{s:8:"sphinxql";s:58:"REPLACE INTO rt (id,gid,title) VALUES (3,333,'test three')";s:14:"total_affected";i:1;}i:46;a:2:{s:8:"sphinxql";s:58:"REPLACE INTO rt (id,gid,title) VALUES (3,444,'test three')";s:14:"total_affected";i:1;}i:47;a:2:{s:8:"sphinxql";s:58:"REPLACE INTO rt (id,gid,title) VALUES (3,555,'test three')";s:14:"total_affected";i:1;}i:48;a:3:{s:8:"sphinxql";s:45:"SELECT *,WEIGHT() FROM rt WHERE MATCH('test')";s:10:"total_rows";i:3;s:4:"rows";a:3:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1621";}i:1;a:3:{s:2:"id";s:1:"2";s:3:"gid";s:3:"111";s:8:"weight()";s:4:"1621";}i:2;a:3:{s:2:"id";s:1:"3";s:3:"gid";s:3:"555";s:8:"weight()";s:4:"1621";}}}}}
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<test>

<name>query cache at RT index</name>

<skip_indexer/>
<config>
indexer
{
mem_limit = 16M
}

searchd
{
<searchd_settings/>
}

index rt
{
type = rt
path = <data_path/>/rt
rt_field = title
rt_attr_uint = gid
}
</config>

<sphqueries>
<sphinxql>SET GLOBAL qcache_thresh_msec=0</sphinxql>
<sphinxql>SET GLOBAL qcache_max_bytes=16777216</sphinxql>
<sphinxql>SET GLOBAL qcache_ttl_sec=3</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (1,111,'test one')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (2,111,'test two')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (3,111,'test three')</sphinxql>

<!-- many dummy segments here -->
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (100,111,'no three'), (101,111,'no three'), (102,111,'no three'), (103,111,'no three'), (104,111,'no three'), (105,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (200,111,'no three'), (201,111,'no three'), (202,111,'no three'), (203,111,'no three'), (204,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (4,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (5,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (6,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (7,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (8,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (9,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (10,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (11,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (12,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (13,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (14,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (15,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (16,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (17,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (18,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (19,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (20,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (21,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (22,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (23,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (24,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (25,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (26,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (27,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (28,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (29,111,'no three')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (30,111,'no three')</sphinxql>

<!-- cached match without actual data at RT index -->
<sphinxql>SELECT *,WEIGHT() FROM rt WHERE MATCH('test')</sphinxql>
<sphinxql>DELETE FROM rt where id=2</sphinxql>
<sphinxql>SELECT *,WEIGHT() FROM rt WHERE MATCH('test')</sphinxql>
<sphinxql>INSERT INTO rt (id,gid,title) VALUES (2,111,'test two')</sphinxql>

<sphinxql>SELECT *,WEIGHT() FROM rt WHERE MATCH('test')</sphinxql>
<sphinxql>REPLACE INTO rt (id,gid,title) VALUES (3,222,'test three')</sphinxql>
<sphinxql>SELECT *,WEIGHT() FROM rt WHERE MATCH('test')</sphinxql>

<!-- cache clean up -->
<sphinxql>SET GLOBAL qcache_max_bytes=0</sphinxql>
<sphinxql>SET GLOBAL qcache_max_bytes=16777216</sphinxql>

<!-- duplicates from segments -->
<sphinxql>SELECT *,WEIGHT() FROM rt WHERE MATCH('test')</sphinxql>
<sphinxql>REPLACE INTO rt (id,gid,title) VALUES (3,333,'test three')</sphinxql>
<sphinxql>REPLACE INTO rt (id,gid,title) VALUES (3,444,'test three')</sphinxql>
<sphinxql>REPLACE INTO rt (id,gid,title) VALUES (3,555,'test three')</sphinxql>
<sphinxql>SELECT *,WEIGHT() FROM rt WHERE MATCH('test')</sphinxql>

</sphqueries>

</test>

0 comments on commit 355b116

Please sign in to comment.