Skip to content

Commit 51182fe

Browse files
committed
Wait replica respond before load it in safe_load()
lua_eval() routine is used for evaluating lua command on a given instance. Before run the command it reconnects to the needed instance and runs it there. After the command run safe_load() is called to parse the result. Found that some times safe_load() routine may fail with AttributeError internal exception. It happens, because result value from running command on the instance was not checked that it was not empty. To fix it was added waiting loop for replica respond before load it in safe_load() routine. Check the following output from gitlab-ci job [1]: DEBUG: sending command: test_run:wait_fullmesh(SERVERS) DEBUG: test-run received command: config engine DEBUG: test-run's response for [config engine] | !!python/unicode 'engine': !!python/unicode 'memtx' | ... DEBUG: test-run received command: eval autobootstrap1 "return box.info.server" DEBUG: test-run's response for [eval autobootstrap1 "return box.info.server"] | - id: null | lsn: -1 | ro: true | uuid: e84d86bd-d2fc-43c1-b832-8146d1f02cd1 | ... DEBUG: test-run received command: eval autobootstrap1 "return box.info.server" DEBUG: test-run's response for [eval autobootstrap1 "return box.info.server"] | - id: null | lsn: -1 | ro: true | uuid: e84d86bd-d2fc-43c1-b832-8146d1f02cd1 | ... DEBUG: test-run received command: eval autobootstrap1 "return box.info.server" TarantoolInpector.handle() received the following error: Traceback (most recent call last): File "test-run/lib/inspector.py", line 100, in handle result = self.parser.parse_preprocessor(line) File "test-run/lib/preprocessor.py", line 87, in parse_preprocessor return self.lua_eval(name, expr[1:-1]) File "test-run/lib/preprocessor.py", line 404, in lua_eval result = yaml.safe_load(result) File "/usr/local/lib/python2.7/site-packages/yaml/__init__.py", line 162, in safe_load return load(stream, SafeLoader) File "/usr/local/lib/python2.7/site-packages/yaml/__init__.py", line 112, in load loader = Loader(stream) File "/usr/local/lib/python2.7/site-packages/yaml/loader.py", line 34, in __init__ Reader.__init__(self, stream) File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 87, in __init__ self.determine_encoding() File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 126, in determine_encoding self.update_raw() File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 183, in update_raw data = self.stream.read(size) AttributeError: 'NoneType' object has no attribute 'read' DEBUG: test-run's response for [eval autobootstrap1 "return box.info.server"] | error: AttributeError("'NoneType' object has no attribute 'read'",) | ... Kill all servers ... [Instance "autobootstrap1" returns with non-zero exit code: 1] It is seen here that wait_fullmesh() routine waits for the server in loop and after successfull 2 checks it fails on the 3rd one. [1] - https://gitlab.com/tarantool/tarantool/-/jobs/878962286 Closes tarantool/tarantool#5572
1 parent e843552 commit 51182fe

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/preprocessor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,11 @@ def lua_eval(self, name, expr, silent=True):
398398
'the nonexistent server {0}'.format(
399399
repr(name)))
400400
self.servers[name].admin.reconnect()
401-
result = self.servers[name].admin(
402-
'%s%s' % (expr, self.delimiter), silent=silent
403-
)
401+
result = None
402+
while not result:
403+
result = self.servers[name].admin(
404+
'%s%s' % (expr, self.delimiter), silent=silent
405+
)
404406
result = yaml.safe_load(result)
405407
if not result:
406408
result = []

0 commit comments

Comments
 (0)