Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbt server fails to reload on HUP if docs block is missing enddocs tag #2066

Closed
drewbanin opened this issue Jan 24, 2020 · 0 comments · Fixed by #2067
Closed

dbt server fails to reload on HUP if docs block is missing enddocs tag #2066

drewbanin opened this issue Jan 24, 2020 · 0 comments · Fixed by #2067
Labels
bug Something isn't working partial_parsing rpc Issues related to dbt's RPC server
Milestone

Comments

@drewbanin
Copy link
Contributor

Describe the bug

When running the dbt server, invalid jinja code can cause the server to get stuck in a "compiling" state. This does not require partial parsing to be enabled.

Steps To Reproduce

  1. Create a file, models/docs.md with the following contents:
{% docs abc%} hi {% enddocs %}
  1. run dbt rpc
  2. Modify models/docs.md to remove the enddocs tag
  3. Send the dbt server process a SIGHUP signal
  4. Observe that the status method on the server returns a compiling state

If you try to run a dbt compile (using dbt v0.15.1 or dev/0.15.2) with the same malformed docs block, you will see:

Running with dbt=0.15.2-a1
Encountered an error:
Traceback (most recent call last):
  File "/Users/drew/fishtown/dbt/core/dbt/main.py", line 80, in main
    results, succeeded = handle_and_check(args)
  File "/Users/drew/fishtown/dbt/core/dbt/main.py", line 158, in handle_and_check
    task, res = run_from_args(parsed)
  File "/Users/drew/fishtown/dbt/core/dbt/main.py", line 210, in run_from_args
    results = task.run()
  File "/Users/drew/fishtown/dbt/core/dbt/task/runnable.py", line 300, in run
    self._runtime_initialize()
  File "/Users/drew/fishtown/dbt/core/dbt/task/runnable.py", line 81, in _runtime_initialize
    super()._runtime_initialize()
  File "/Users/drew/fishtown/dbt/core/dbt/task/runnable.py", line 54, in _runtime_initialize
    self.load_manifest()
  File "/Users/drew/fishtown/dbt/core/dbt/task/runnable.py", line 46, in load_manifest
    self.manifest = get_full_manifest(self.config)
  File "/Users/drew/fishtown/dbt/core/dbt/perf_utils.py", line 23, in get_full_manifest
    return load_manifest(config, internal, set_header)
  File "/Users/drew/fishtown/dbt/core/dbt/parser/manifest.py", line 441, in load_manifest
    return ManifestLoader.load_all(config, internal_manifest, macro_hook)
  File "/Users/drew/fishtown/dbt/core/dbt/parser/manifest.py", line 329, in load_all
    loader.load(internal_manifest=internal_manifest)
  File "/Users/drew/fishtown/dbt/core/dbt/parser/manifest.py", line 200, in load
    self.parse_project(project, macro_manifest, old_results)
  File "/Users/drew/fishtown/dbt/core/dbt/parser/manifest.py", line 174, in parse_project
    self.parse_with_cache(path, parser, old_results)
  File "/Users/drew/fishtown/dbt/core/dbt/parser/manifest.py", line 133, in parse_with_cache
    parser.parse_file(block)
  File "/Users/drew/fishtown/dbt/core/dbt/parser/docs.py", line 90, in parse_file
    for block in searcher:
  File "/Users/drew/fishtown/dbt/core/dbt/parser/search.py", line 125, in __iter__
    for block in self.extract_blocks(entry):
  File "/Users/drew/fishtown/dbt/core/dbt/parser/search.py", line 110, in extract_blocks
    collect_raw_data=False
  File "/Users/drew/fishtown/dbt/core/dbt/clients/jinja.py", line 399, in extract_toplevel_blocks
    collect_raw_data=collect_raw_data
  File "/Users/drew/fishtown/dbt/core/dbt/clients/_jinja_blocks.py", line 371, in lex_for_blocks
    collect_raw_data=collect_raw_data))
  File "/Users/drew/fishtown/dbt/core/dbt/clients/_jinja_blocks.py", line 362, in find_blocks
    ).format(self.current))
  File "/Users/drew/fishtown/dbt/core/dbt/exceptions.py", line 357, in raise_compiler_error
    raise CompilationException(msg, node)
dbt.exceptions.CompilationException: <exception str() failed>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/drew/fishtown/dbt/env/bin/dbt", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/Users/drew/fishtown/dbt/core/scripts/dbt", line 7, in <module>
    dbt.main.main(sys.argv[1:])
  File "/Users/drew/fishtown/dbt/core/dbt/main.py", line 96, in main
    logger.warning(str(e))
  File "/Users/drew/fishtown/dbt/core/dbt/exceptions.py", line 99, in __str__
    node_string = " in {}".format(self.node_to_string(self.node))
  File "/Users/drew/fishtown/dbt/core/dbt/exceptions.py", line 66, in node_to_string
    node.resource_type,
AttributeError: 'NotImplementedType' object has no attribute 'resource_type'

My guess is that this that the exception raised during exception handling is the culprit here, but I'm not certain of that.

Expected behavior

I would expect the server to be in an "error" state after HUPing the server with invalid dbt code.

The output of dbt --version:
Reproduced with v0.15.1 and dev/0.15.2

The operating system you're using: macOS

@drewbanin drewbanin added bug Something isn't working rpc Issues related to dbt's RPC server labels Jan 24, 2020
@drewbanin drewbanin added this to the 0.15.2 milestone Jan 24, 2020
beckjake added a commit that referenced this issue Jan 24, 2020
…-hang

fix an RPC hang when enddocs tags were missing (#2066)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working partial_parsing rpc Issues related to dbt's RPC server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants