@@ -4,6 +4,7 @@ local vshard = require('vshard')
44local fiber = require (' fiber' )
55
66local call = require (' crud.common.call' )
7+ local const = require (' crud.common.const' )
78local utils = require (' crud.common.utils' )
89local sharding = require (' crud.common.sharding' )
910local filters = require (' crud.compare.filters' )
@@ -122,7 +123,7 @@ local function call_count_on_router(space_name, user_conditions, opts)
122123
123124 local space = utils .get_space (space_name , replicasets )
124125 if space == nil then
125- return nil , CountError :new (" Space %q doesn't exist" , space_name ), true
126+ return nil , CountError :new (" Space %q doesn't exist" , space_name ), const . NEED_SCHEMA_RELOAD
126127 end
127128
128129 local sharding_key_data , err = sharding_metadata_module .fetch_sharding_key_on_router (space_name )
@@ -135,7 +136,7 @@ local function call_count_on_router(space_name, user_conditions, opts)
135136 sharding_key_as_index_obj = sharding_key_data .value ,
136137 })
137138 if err ~= nil then
138- return nil , CountError :new (" Failed to plan count: %s" , err ), true
139+ return nil , CountError :new (" Failed to plan count: %s" , err ), const . NEED_SCHEMA_RELOAD
139140 end
140141
141142 -- set replicasets to count from
@@ -188,7 +189,7 @@ local function call_count_on_router(space_name, user_conditions, opts)
188189 local err
189190 replicasets_to_count , err = sharding .get_replicasets_by_bucket_id (bucket_id_data .bucket_id )
190191 if err ~= nil then
191- return nil , err , true
192+ return nil , err , const . NEED_SCHEMA_RELOAD
192193 end
193194 else
194195 skip_sharding_hash_check = true
@@ -219,7 +220,13 @@ local function call_count_on_router(space_name, user_conditions, opts)
219220 }, call_opts )
220221
221222 if err ~= nil then
222- return nil , CountError :new (" Failed to call count on storage-side: %s" , err )
223+ local err_wrapped = CountError :new (" Failed to call count on storage-side: %s" , err )
224+
225+ if sharding .result_needs_sharding_reload (err ) then
226+ return nil , err_wrapped , const .NEED_SHARDING_RELOAD
227+ end
228+
229+ return nil , err_wrapped
223230 end
224231
225232 if results .err ~= nil then
@@ -289,7 +296,8 @@ function count.call(space_name, user_conditions, opts)
289296 mode = ' ?string' ,
290297 })
291298
292- return schema .wrap_func_reload (call_count_on_router , space_name , user_conditions , opts )
299+ return schema .wrap_func_reload (sharding .wrap_method ,
300+ call_count_on_router , space_name , user_conditions , opts )
293301end
294302
295303return count
0 commit comments