anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: edgedb/edgedb
Issue: Indexes on Computed Properties cause Invalid Reference Error

EdgeDB 4.0-dev.7528+local (repl 3.1.0-dev)


Reproduction:
1. run `edb cli migration create` on the following schema:

```
module default {
type Person {

    required property name -> str;
    
    property name2 := .name;

    index on (.name2);
}

}
```

The error is:
```
edgedb error: InvalidReferenceError: object type 'default::Person' has no link or property 'name2' (on line 1, column 1)
  Hint: did you mean 'name'?
<stacktraces>
        File "edgedb/edb/edgeql/compiler/setgen.py", line 843, in resolve_ptr_with_intersections
      edb.errors.InvalidReferenceError: object type 'default::Person' has no link or property 'name2'
```

Changed files:
edb/edgeql/compiler/setgen.py, tests/test_schema.py

diff --git a/edb/edgeql/compiler/setgen.py b/edb/edgeql/compiler/setgen.py
index 9889fcff5..9a86037fb 100644
--- a/edb/edgeql/compiler/setgen.py
+++ b/edb/edgeql/compiler/setgen.py
@@ -726,6 +726,15 @@ def resolve_ptr_with_intersections(
         if ptr is not None:
             ref = ptr.get_nearest_non_derived_parent(ctx.env.schema)
             if track_ref is not False:
+                # XXX: This condition is a hack that approximates what
+                # really exists in the schema and what does not exist.
+                # The approximation is: a computed pointer that does not
+                # come from an alias exists in the schema, even it is derived.
+                if (ref != ptr and
+                        ptr.get_computable(ctx.env.schema) and
+                        not ptr.get_from_alias(ctx.env.schema)):
+                    ctx.env.add_schema_ref(ptr, track_ref)
+
                 ctx.env.add_schema_ref(ref, track_ref)
                 _add_target_schema_refs(
                     ref.get_target(ctx.env.schema), ctx=ctx)
diff --git a/tests/test_schema.py b/tests/test_schema.py
index 1ff1da506..389fb6455 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -6214,6 +6214,21 @@ class TestGetMigration(tb.BaseSchemaLoadTest):
             }
         """])
 
+    def test_schema_migrations_equivalence_index_06(self):
+        self._assert_migration_equivalence([r"""
+            type Base {
+                property first_name -> str;
+                property name := .first_name;
+            }
+        """, r"""
+            type Base {
+                property first_name -> str;
+                property name := .first_name;
+                # an index on a computable
+                index on (.name);
+            }
+        """])
+
     def test_schema_migrations_equivalence_constraint_01(self):
         self._assert_migration_equivalence([r"""
             type Base {
Repository: matrix-org/synapse
Issue: Sending AS transactions can wedge if network connectivity drops

The freenode bridge had a 9h outage caused by our cloud provider dropping temporarily. Synapse survived the drop, but in-flight requests got wedged and never timed out. We should have application level timeouts for outbound HTTP requests.

Changed files:
synapse/http/client.py

diff --git a/synapse/http/client.py b/synapse/http/client.py
index 9cf797043a..9eba046bbf 100644
--- a/synapse/http/client.py
+++ b/synapse/http/client.py
@@ -19,6 +19,7 @@ from synapse.api.errors import (
     CodeMessageException, MatrixCodeMessageException, SynapseError, Codes,
 )
 from synapse.util.logcontext import preserve_context_over_fn
+from synapse.util import logcontext
 import synapse.metrics
 from synapse.http.endpoint import SpiderEndpoint
 
@@ -72,39 +73,45 @@ class SimpleHttpClient(object):
             contextFactory=hs.get_http_client_context_factory()
         )
         self.user_agent = hs.version_string
+        self.clock = hs.get_clock()
         if hs.config.user_agent_suffix:
             self.user_agent = "%s %s" % (self.user_agent, hs.config.user_agent_suffix,)
 
+    @defer.inlineCallbacks
     def request(self, method, uri, *args, **kwargs):
         # A small wrapper around self.agent.request() so we can easily attach
         # counters to it
         outgoing_requests_counter.inc(method)
-        d = preserve_context_over_fn(
-            self.agent.request,
-            method, uri, *args, **kwargs
-        )
+
+        def send_request():
+            request_deferred = self.agent.request(
+                method, uri, *args, **kwargs
+            )
+
+            return self.clock.time_bound_deferred(
+                request_deferred,
+                time_out=60,
+            )
 
         logger.info("Sending request %s %s", method, uri)
 
-        def _cb(response):
+        try:
+            with logcontext.PreserveLoggingContext():
+                response = yield send_request()
+
             incoming_responses_counter.inc(method, response.code)
             logger.info(
                 "Received response to  %s %s: %s",
                 method, uri, response.code
             )
-            return response
-
-        def _eb(failure):
+            defer.returnValue(response)
+        except Exception as e:
             incoming_responses_counter.inc(method, "ERR")
             logger.info(
                 "Error sending request to  %s %s: %s %s",
-                method, uri, failure.type, failure.getErrorMessage()
+                method, uri, type(e).__name__, e.message
             )
-            return failure
-
-        d.addCallbacks(_cb, _eb)
-
-        return d
+            raise e
 
     @defer.inlineCallbacks
     def post_urlencoded_get_json(self, uri, args={}):
Repository: chia-network/chia-blockchain
Issue: [Bug] Windows CLI: Ctrl-C in console will cause Daemon to close despite it appearing to be running in the background

### What happened?

Start node with `chia start node`
After node and daemon are started type Ctrl-C
Daemon will exit

(happens in both cmd.exe and PowerShell)

The Daemon does not detach from the console so it receives keyboard interrupts from the console as long as it remains running.

See https://github.com/Chia-Network/chia-blockchain/blob/764a5a22761f10da1811ed8129224db04602c1c6/chia/cmds/start_funcs.py#L20

### Version

1.5.1 and earlier

### What platform are you using?

Windows

### What ui mode are you using?

CLI

### Relevant log output

```shell
N/A
```


Changed files:
chia/cmds/start_funcs.py

diff --git a/chia/cmds/start_funcs.py b/chia/cmds/start_funcs.py
index ed33b80f9..41aea357b 100644
--- a/chia/cmds/start_funcs.py
+++ b/chia/cmds/start_funcs.py
@@ -17,8 +17,17 @@ from chia.util.service_groups import services_for_groups
 
 def launch_start_daemon(root_path: Path) -> subprocess.Popen:
     os.environ["CHIA_ROOT"] = str(root_path)
-    # TODO: use startupinfo=subprocess.DETACHED_PROCESS on windows
-    process = subprocess.Popen([sys.argv[0], "run_daemon", "--wait-for-unlock"], stdout=subprocess.PIPE)
+    creationflags = 0
+    if sys.platform == "win32":
+        creationflags = subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_NO_WINDOW
+
+    process = subprocess.Popen(
+        [sys.argv[0], "run_daemon", "--wait-for-unlock"],
+        encoding="utf-8",
+        stdout=subprocess.PIPE,
+        creationflags=creationflags,
+    )
+
     return process
Repository: chia-network/chia-blockchain
Issue: [Bug] BrokenPipeError when stopping data_layer from CLI

### What happened?

When doing `chia stop data` at the command line, the following error is shown:

```
chia_data_layer: Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
```
Seems like it does actually stop the service successfully and I haven't found any problems with the service after restarting.  

### Version

1.6.0

### What platform are you using?

Linux

### What ui mode are you using?

CLI

### Relevant log output

```shell
2022-09-26T15:24:26.692 data_layer data_layer             : INFO     Waiting for service _await_closed callback
2022-09-26T15:24:26.694 data_layer data_layer             : INFO     Service data_layer at port 8561 fully closed
2022-09-26T15:24:26.917 data_layer asyncio                : ERROR    Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0xffff7c105240>
```

Running on Ubuntu on ARM, installed Chia from source. Connected to Testnet10.  

Changed files:
chia/server/start_data_layer.py

diff --git a/chia/server/start_data_layer.py b/chia/server/start_data_layer.py
index ef6a1f982..e9eee0765 100644
--- a/chia/server/start_data_layer.py
+++ b/chia/server/start_data_layer.py
@@ -1,8 +1,10 @@
 from __future__ import annotations
 
+import contextlib
 import logging
 import pathlib
 import sys
+from io import TextIOWrapper
 from typing import Any, Dict, Optional, cast
 
 from chia.data_layer.data_layer import DataLayer
@@ -25,6 +27,20 @@ SERVICE_NAME = "data_layer"
 log = logging.getLogger(__name__)
 
 
+class StdOutputLogger(TextIOWrapper):
+    def __init__(self, logger: logging.Logger, level: int = logging.INFO) -> None:
+        self.logger = logger
+        self.level = level
+
+    def write(self, message: str) -> int:
+        if message and not message.isspace():
+            self.logger.log(self.level, message)
+        return 0
+
+    def flush(self) -> None:
+        pass
+
+
 # TODO: Review need for config and if retained then hint it properly.
 def create_data_layer_service(
     root_path: pathlib.Path,
@@ -79,16 +95,19 @@ async def async_main() -> int:
         root_path=DEFAULT_ROOT_PATH,
     )
 
-    create_all_ssl(
-        root_path=DEFAULT_ROOT_PATH,
-        private_node_names=["data_layer"],
-        public_node_names=["data_layer"],
-        overwrite=False,
-    )
-
-    service = create_data_layer_service(DEFAULT_ROOT_PATH, config)
-    await service.setup_process_global_state()
-    await service.run()
+    with contextlib.redirect_stdout(
+        StdOutputLogger(log, logging.INFO)
+    ) if not sys.stdout.isatty() else contextlib.nullcontext():
+        create_all_ssl(
+            root_path=DEFAULT_ROOT_PATH,
+            private_node_names=["data_layer"],
+            public_node_names=["data_layer"],
+            overwrite=False,
+        )
+
+        service = create_data_layer_service(DEFAULT_ROOT_PATH, config)
+        await service.setup_process_global_state()
+        await service.run()
 
     return 0