Skip to content

Commit a7d44a2

Browse files
committed
Make select error more informative
Report "crud is not initialized" error if storage functions are not defined. Before this patch, select error description does not give any clues about possible causes of undefined storage functions. Part of #229
1 parent 1635f16 commit a7d44a2

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
### Added
1111

1212
### Changed
13+
* Make select error description more informative in case
14+
of disabled/uninit storage.
1315

1416
### Fixed
1517

crud/common/call.lua

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ local sharding_utils = require('crud.common.sharding.utils')
77
local fiber_clock = require('fiber').clock
88

99
local CallError = errors.new_class('CallError')
10-
local NotInitializedError = errors.new_class('NotInitialized')
1110

1211
local call = {}
1312

@@ -46,16 +45,6 @@ local function wrap_vshard_err(err, func_name, replicaset_uuid, bucket_id)
4645
return errors.wrap(err)
4746
end
4847

49-
if err.type == 'ClientError' and type(err.message) == 'string' then
50-
if err.message == string.format("Procedure '%s' is not defined", func_name) then
51-
if func_name:startswith('_crud.') then
52-
err = NotInitializedError:new("crud isn't initialized on replicaset: %q", replicaset_uuid)
53-
else
54-
err = NotInitializedError:new("Function %s is not registered", func_name)
55-
end
56-
end
57-
end
58-
5948
if replicaset_uuid == nil then
6049
local replicaset, _ = vshard.router.route(bucket_id)
6150
if replicaset == nil then
@@ -67,6 +56,7 @@ local function wrap_vshard_err(err, func_name, replicaset_uuid, bucket_id)
6756
replicaset_uuid = replicaset.uuid
6857
end
6958

59+
err = utils.update_storage_call_error_description(err, func_name, replicaset_uuid)
7060
err = errors.wrap(err)
7161

7262
return CallError:new(utils.format_replicaset_error(

crud/common/utils.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ local ParseOperationsError = errors.new_class('ParseOperationsError', {capture_s
1414
local ShardingError = errors.new_class('ShardingError', {capture_stack = false})
1515
local GetSpaceFormatError = errors.new_class('GetSpaceFormatError', {capture_stack = false})
1616
local FilterFieldsError = errors.new_class('FilterFieldsError', {capture_stack = false})
17+
local NotInitializedError = errors.new_class('NotInitialized')
1718

1819
local utils = {}
1920

@@ -692,4 +693,22 @@ function utils.check_name_isident(name)
692693
return true
693694
end
694695

696+
function utils.update_storage_call_error_description(err, func_name, replicaset_uuid)
697+
if err == nil then
698+
return nil
699+
end
700+
701+
if err.type == 'ClientError' and type(err.message) == 'string' then
702+
if err.message == string.format("Procedure '%s' is not defined", func_name) then
703+
if func_name:startswith('_crud.') then
704+
err = NotInitializedError:new("crud isn't initialized on replicaset: %q",
705+
replicaset_uuid or "Unknown")
706+
else
707+
err = NotInitializedError:new("Function %s is not registered", func_name)
708+
end
709+
end
710+
end
711+
return err
712+
end
713+
695714
return utils

crud/select/merger.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ local merger_lib = compat.require('tuple.merger', 'merger')
1111

1212
local Keydef = require('crud.compare.keydef')
1313
local stats = require('crud.stats')
14+
local utils = require("crud.common.utils")
1415

1516
local function bswap_u16(num)
1617
return bit.rshift(bit.bswap(tonumber(num)), 16)
@@ -113,7 +114,8 @@ local function fetch_chunk(context, state)
113114
-- Wait for requested data.
114115
local res, err = future:wait_result(timeout)
115116
if res == nil then
116-
error(err)
117+
local wrapped_err = errors.wrap(utils.update_storage_call_error_description(err, func_name, replicaset.uuid))
118+
error(wrapped_err)
117119
end
118120

119121
-- Decode metainfo, leave data to be processed by the merger.

0 commit comments

Comments
 (0)