Substra/substra-backend

Error PHANTOM_READ_CONFLICT

Closed this issue · 1 comments

I was adding lots of chained tuples on the demo env and the execution of the very first one failed with the following traceback in the worker:

[2020-01-09 10:29:11,067: ERROR/ForkPoolWorker-1] ['PHANTOM_READ_CONFLICT', 'PHANTOM_READ_CONFLICT', 'PHANTOM_READ_CONFLICT', 'PHANTOM_READ_CONFLICT']
Traceback (most recent call last):
  File "/usr/src/app/substrapp/ledger_utils.py", line 167, in call_ledger
    response = loop.run_until_complete(chaincode_calls[call_type](**params))
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.6/dist-packages/hfc/fabric/client.py", line 1729, in chaincode_invoke
    raise Exception(statuses)
Exception: ['PHANTOM_READ_CONFLICT', 'PHANTOM_READ_CONFLICT', 'PHANTOM_READ_CONFLICT', 'PHANTOM_READ_CONFLICT']

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/substrapp/ledger_utils.py", line 180, in call_ledger
    response = [r for r in e.args[0] if r.response.status != 200][0].response.message
  File "/usr/src/app/substrapp/ledger_utils.py", line 180, in <listcomp>
    response = [r for r in e.args[0] if r.response.status != 200][0].response.message
AttributeError: 'str' object has no attribute 'response'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/substrapp/tasks/tasks.py", line 472, in on_success
    log_success_tuple(tuple_type, subtuple['key'], retval['result'])
  File "/usr/src/app/substrapp/ledger_utils.py", line 371, in log_success_tuple
    _update_tuple_status(tuple_type, tuple_key, 'done', extra_kwargs=extra_kwargs)
  File "/usr/src/app/substrapp/ledger_utils.py", line 324, in _update_tuple_status
    update_ledger(fcn=invoke_fcn, args=invoke_args, sync=True)
  File "/usr/src/app/substrapp/ledger_utils.py", line 107, in _wrapper
    return fn(*args, **kwargs)
  File "/usr/src/app/substrapp/ledger_utils.py", line 233, in update_ledger
    return _invoke_ledger(*args, **kwargs)
  File "/usr/src/app/substrapp/ledger_utils.py", line 212, in _invoke_ledger
    response = call_ledger('invoke', fcn=fcn, args=args, kwargs=params)
  File "/usr/src/app/substrapp/ledger_utils.py", line 182, in call_ledger
    raise LedgerError(str(e))
substrapp.ledger_utils.LedgerError: ['PHANTOM_READ_CONFLICT', 'PHANTOM_READ_CONFLICT', 'PHANTOM_READ_CONFLICT', 'PHANTOM_READ_CONFLICT']
[2020-01-09 10:29:11,078: INFO/ForkPoolWorker-1] Task substrapp.tasks.tasks.compute_task[96d4f391-356b-41a8-a90f-419a43c8ce00] succeeded in 2.1781632349884603s: {'worker': 'Org1.worker', 'queue': 'Org1.worker', 'computePlanID': '0ac595c5cfcd1711446bcb8f68df720e09f0252
aac948994e7d54e236d198536', 'result': {'end_head_model_file_hash': '6485c28e994d905ef74b77026a48b18914cf1562049085a329f99981841185ed', 'end_head_model_file': 'https://substra-backend.org1.substra-demo.owkin.com/model/6485c28e994d905ef74b77026a48b18914cf1562049085a329f
99981841185ed/file/', 'end_trunk_model_file_hash': 'ed30311078bfc91cec7a2b6d027bfa4cd45de7f5056609fe29d92d4e5ffad984', 'end_trunk_model_file': 'https://substra-backend.org1.substra-demo.owkin.com/model/ed30311078bfc91cec7a2b6d027bfa4cd45de7f5056609fe29d92d4e5ffad984/f
ile/'}}

See #94 for a potential fix.

Fixed by #94