gRPC not receiving responses due to queue_timeout? - grpc

I have a simple gRPC client/server application. The server starts and the client pings(verified by server-side code); however I don't receive responses.
I narrowed it down to this line on the server-side. I am not sure what could cause a queue_timeout. I am following this
.proto:
1 syntax = "proto3";
2
3 service Pinger {
4 rpc Ping (PingMessage) returns (PongMessage) {}
5 }
6
7 message PingMessage{
8 string message = 1;
9 }
10
11 message PongMessage {
12 string message = 1;
13 }
server.py:
class Pinger(PingerServicer):
def Ping(self, request, context):
return grpc_service_pb2.PongMessage(message = "pong")
grpc_server_app = Pinger()
client.py:
class GRPCClient:
def __init__(self):
self.host = "localhost"
self.port = GRPC_PORT
#timeit('grpc')
def send(self, channel):
stub = grpc_service_pb2_grpc.PingerStub(channel)
ping_message = grpc_service_pb2.PingMessage(message = 'ping')
response = stub.Ping(ping_message)
def run(self):
with grpc.insecure_channel(f"{self.host}:{self.port}") as channel:
while True:
self.send(channel)
main.py
17 def grpc_server_wrapper():
18 server = grpc.server(ThreadPoolExecutor(max_workers=2))
19 grpc_service_pb2_grpc.add_PingerServicer_to_server(grpc_server_app, server)
20 server.add_insecure_port('[::]:' + str(GRPC_PORT))
21 server.start()
22 print("Server started, listening on " + str(GRPC_PORT))
23 server.wait_for_termination()
24
25 if __name__ == '__main__':
26 futures = []
27 with ProcessPoolExecutor(max_workers = 2) as executor:
46 futures.append(
47 executor.submit(grpc_client_app.run)
48 )
49
50 futures.append(
51 executor.submit(grpc_server_wrapper)
52 )
56 [f.result() for f in futures]

The problem was that the server was not ready when the client was trying to ping and thus it would err out and die. The error was swallowed by the process pool.
The solution is to add wait_for_ready = True to the client call:
response = stub.Ping(ping_message, wait_for_ready = True)

Related

Geting error Caused by: com.databricks.NotebookExecutionException: FAILED

I am trying to run the below notebook through databricks but getting the below error. I have tried to update the notebook timeout and the retry mechanism but still no luck yet.
NotebookData("/Users/mynotebook",9900, retry=3)
]
res = parallelNotebooks(notebooks, 2)
result = [f.result(timeout=9900) for f in res] # This is a blocking call.
print(result)
Can someone please help me to sort out this issue? Thanks
%python
from concurrent.futures import ThreadPoolExecutor
class NotebookData:
def __init__(self, path, timeout, parameters=None, retry=0):
self.path = path
self.timeout = timeout
self.parameters = parameters
self.retry = retry
def submitNotebook(notebook):
print("Running notebook %s" % notebook.path)
try:
if (notebook.parameters):
return dbutils.notebook.run(notebook.path, notebook.timeout, notebook.parameters)
else:
return dbutils.notebook.run(notebook.path, notebook.timeout)
except Exception:
if notebook.retry < 1:
raise
print("Retrying notebook %s" % notebook.path)
notebook.retry = notebook.retry - 1
submitNotebook(notebook)
def parallelNotebooks(notebooks, numInParallel):
# This code limits the number of parallel notebooks.
with ThreadPoolExecutor(max_workers=numInParallel) as ec:
return [ec.submit(submitNotebook, notebook) for notebook in notebooks]
notebooks = [
NotebookData("/Users/mynotebook",1200000, retry=0)
]
res = parallelNotebooks(notebooks, 2)
result = [f.result(timeout=1200000) for f in res] # This is a blocking call.
print(result)
Error:
Py4JJavaError Traceback (most recent call last)
<command-1143841910698378> in <module>
32 ]
33 res = parallelNotebooks(notebooks, 2)
---> 34 result = [f.result(timeout=1200000) for f in res] # This is a blocking call.
35 print(result)
<command-1143841910698378> in <listcomp>(.0)
32 ]
33 res = parallelNotebooks(notebooks, 2)
---> 34 result = [f.result(timeout=1200000) for f in res] # This is a blocking call.
35 print(result)
/usr/lib/python3.7/concurrent/futures/_base.py in result(self, timeout)
426 raise CancelledError()
427 elif self._state == FINISHED:
--> 428 return self.__get_result()
429
430 self._condition.wait(timeout)
/usr/lib/python3.7/concurrent/futures/_base.py in __get_result(self)
382 def __get_result(self):
383 if self._exception:
--> 384 raise self._exception
385 else:
386 return self._result
/usr/lib/python3.7/concurrent/futures/thread.py in run(self)
55
56 try:
---> 57 result = self.fn(*self.args, **self.kwargs)
58 except BaseException as exc:
59 self.future.set_exception(exc)
<command-1143841910698378> in submitNotebook(notebook)
12 return dbutils.notebook.run(notebook.path, notebook.timeout, notebook.parameters)
13 else:
---> 14 return dbutils.notebook.run(notebook.path, notebook.timeout)
15 except Exception:
16 if notebook.retry < 1:
/local_disk0/tmp/1664351986642-0/dbutils.py in run(self, path, timeout_seconds, arguments, _NotebookHandler__databricks_internal_cluster_spec)
136 arguments,
137 __databricks_internal_cluster_spec,
--> 138 self.shell.currentJobGroup)
139
140 def __repr__(self):
/databricks/spark/python/lib/py4j-0.10.9-src.zip/py4j/java_gateway.py in __call__(self, *args)
1303 answer = self.gateway_client.send_command(command)
1304 return_value = get_return_value(
-> 1305 answer, self.gateway_client, self.target_id, self.name)
1306
1307 for temp_arg in temp_args:
/databricks/spark/python/pyspark/sql/utils.py in deco(*a, **kw)
125 def deco(*a, **kw):
126 try:
--> 127 return f(*a, **kw)
128 except py4j.protocol.Py4JJavaError as e:
129 converted = convert_exception(e.java_exception)
/databricks/spark/python/lib/py4j-0.10.9-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
326 raise Py4JJavaError(
327 "An error occurred while calling {0}{1}{2}.\n".
--> 328 format(target_id, ".", name), value)
329 else:
330 raise Py4JError(
Py4JJavaError: An error occurred while calling o1741._run.
: com.databricks.WorkflowException: com.databricks.NotebookExecutionException: FAILED
at com.databricks.workflow.WorkflowDriver.run(WorkflowDriver.scala:95)
at com.databricks.dbutils_v1.impl.NotebookUtilsImpl.run(NotebookUtilsImpl.scala:122)
at com.databricks.dbutils_v1.impl.NotebookUtilsImpl._run(NotebookUtilsImpl.scala:89)
at sun.reflect.GeneratedMethodAccessor820.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:380)
at py4j.Gateway.invoke(Gateway.java:295)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:251)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.databricks.NotebookExecutionException: FAILED
at com.databricks.workflow.WorkflowDriver.run0(WorkflowDriver.scala:141)
at com.databricks.workflow.WorkflowDriver.run(WorkflowDriver.scala:90)
... 12 more

Why can't I handle 300 get responses with async?

As part of my homework project, I'm working with imdb.com pages.
For one task I need to make 320 get-requests to turn them into beautifulsoup objects later on.
I'm trying to do that the async way and so far I got this:
def get_tasks(session, url_links):
tasks = []
num = 1 # debugging purposes
for url in url_links:
tasks.append(session.get(url, headers={'Accept-Language': 'en', 'X_FORWARDED_FOR': '2.21.184.0'}, ssl=False))
time.sleep(1) # avoid 503 status_code
print(f"Number of responses get_tasks: {num}") # debugging purposes
num += 1 # debugging purposes
return tasks
# Getting response.texts
results = []
async def get_response_texts(url_links):
async with aiohttp.ClientSession() as session:
tasks = get_tasks(session, url_links)
responses = await asyncio.gather(*tasks)
t1 = time.perf_counter()
num = 1
for response in responses:
results.append(await response.text())
print(f"{num} responses processed") # debugging purposes
num += 1
t2 = time.perf_counter()
print(f'Asynchronous execution: Finished in {t2 - t1} seconds\n')
if __name__ == '__main__':
links = [a list of urls to films as strings]
asyncio.run(get_response_texts(links))
print(len(results))
Here comes the problem: When I process 100 requests, things seem all right, but when I make 300, I get asyncio.exceptions.TimeoutError.
Why is it so and how can I avoid that and make 320 requests asynchronously?

Firestore call setData will not enter completion block after signOut and signIn firebase auth on iOS

In iOS (swift) with Firebase SDK
Using Firebase (4.10.0)
Using FirebaseAuth (4.4.4)
Using FirebaseCore (4.0.16)
Using FirebaseFirestore (0.10.2)
Problem happen when
signIn (anonymous or with credential)
signOut
signIn
call FIRDocumentReference.setData then completion block of setData will never called
Problem will not happen if
signOut
terminate app
signIn
call FIRDocumentReference.setData everything work fine
import UIKit
import Firebase
class ViewController: UIViewController {
let mEmail = "tester#xxxxx.com"
let mPassword = "xxxxx"
override func viewDidLoad() {
super.viewDidLoad()
}
#IBAction func clickSignIn(_ sender: Any) {
print("clickSignIn")
Auth.auth().signIn(withEmail: mEmail, password: mPassword) { (user, error) in
print("user:", user ?? "no user")
print("error:", error ?? "no error")
}
}
#IBAction func clickSignOut(_ sender: Any) {
print("clickSignOut")
do {
try Auth.auth().signOut()
} catch {
print("can't signOut")
}
print(Auth.auth().currentUser ?? "no user")
}
#IBAction func clickSetData(_ sender: Any) {
print("clickSetData")
let ref = Firestore.firestore().document("tests/test_1")
let data = ["text": "xxxxx"]
ref.setData(data, options: SetOptions.merge()) { (e) in
if (e == nil) {
print("setData complete")
} else {
print("setData error:", e ?? "no error")
}
}
}
}
And sometime it cause this crash too
*** Assertion failure in -[FSTLevelDBMutationQueue removeMutationBatches:group:], third_party/firebase/ios/Source/Firestore/Source/Local/FSTLevelDBMutationQueue.mm:536
2018-03-08 03:56:22.364597+0700 setdata-bug[30957:9502011] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: Mutation batch [mutation: userID=\^X8I\^G\^A batchID=5] not found; found [mutation: userID=P¸P››\^? batchID=0]'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a05c12b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001096f0f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010a0612f2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000109191d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 setdata-bug 0x0000000107333229 -[FSTLevelDBMutationQueue removeMutationBatches:group:] + 1967
5 setdata-bug 0x000000010733fc8e -[FSTLocalStore removeMutationBatches:group:] + 885
6 setdata-bug 0x000000010733f753 -[FSTLocalStore releaseBatchResults:group:remoteDocuments:] + 537
7 setdata-bug 0x000000010733c4f7 -[FSTLocalStore acknowledgeBatchWithResult:] + 571
8 setdata-bug 0x0000000107321e36 -[FSTSyncEngine applySuccessfulWriteWithResult:] + 166
9 setdata-bug 0x0000000107363325 -[FSTRemoteStore writeStreamDidReceiveResponseWithVersion:mutationResults:] + 300
10 setdata-bug 0x0000000107373069 -[FSTWriteStream handleStreamMessage:] + 847
11 setdata-bug 0x00000001073712da -[FSTStream writeValue:] + 477
12 setdata-bug 0x000000010736ee73 -[FSTCallbackFilter writeValue:] + 84
13 RxLibrary 0x00000001086065d6 __57-[GRXConcurrentWriteable enqueueValue:completionHandler:]_block_invoke + 86
14 libdispatch.dylib 0x000000010b0cd2f7 _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x000000010b0ce33d _dispatch_client_callout + 8
16 libdispatch.dylib 0x000000010b0d6855 _dispatch_queue_serial_drain + 1162
17 libdispatch.dylib 0x000000010b0d71ea _dispatch_queue_invoke + 336
18 libdispatch.dylib 0x000000010b0d2f7c _dispatch_queue_override_invoke + 733
19 libdispatch.dylib 0x000000010b0da102 _dispatch_root_queue_drain + 772
20 libdispatch.dylib 0x000000010b0d9da0 _dispatch_worker_thread3 + 132
21 libsystem_pthread.dylib 0x000000010d8051ca _pthread_wqthread + 1387
22 libsystem_pthread.dylib 0x000000010d804c4d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
It was confirmed by google engineers that the issue I've identified is a known bug on the latest iOS SDK version (4.10.0). The good news is that, it was already fixed in the following pull requests: 890, 893. Until the fixes has been publicly released, Google suggest us to temporarily downgrade to version 4.9.0 for now. Any specifics or timeline can't be shared at the moment so please keep an eye out on our release notes for any updates.

ORA-12505 + "network adapter could not establish the connection" on Oracle11g/VirtualBox

I have Oracle 11g installed locally on each of my virtualbox machines (working under Windows 7 64bit). Suddenty, after a simple reboot, the database on one of the 5 virtual machines doesn't want to connect anymore.
With SID connection I obtain ORA-12505 error, and with service name : "Network adapter could not establish the connection", in SqlDeveloper with both cases. If I try a connection with SqlPlus as sysdba, I obtain the connection but with "connected to an idle instance". Hence if I try to see, for example, the list of sessions and processes working, I have the error 01034 ("ORACLE not available"). I tried a lot of tricks but nothing works. Could it be a specific problem with virtual machines ?
Here what I tried :
the services (of my base and of the listener) are working (and I wait enough between relaunch and connection retry) ;
the files tnsnames.ora, listener.ora and sqlnet.ora seem correct (see below) ;
If I force localhost to be 127.0.0.1 in hosts file, I have the 12514 error ;
ORACLE_HOME and ORACLE_SID are correctly set ;
It can't a priori be a memory problem (I even try to allow more memory to the specific VM which doesn't work) ;
If I force "startup" on sysdba session, the next requests obtain : ORA-03114 : not connected to ORACLE ;
It's not a priori a problem of system files size. In all cases, the not working database is not my biggest database among all my databases (and any file in oradata are bigger than in others VMs which have exactly the same configurations).
# tnsnames.ora Network Configuration File: C:\oracle_32\product\11.2.0\dbhome_2\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
# listener.ora Network Configuration File: C:\oracle_32\product\11.2.0\dbhome_2\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\oracle_32\product\11.2.0\dbhome_2)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\oracle_32\product\11.2.0\dbhome_2\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
ADR_BASE_LISTENER = C:\oracle_32
Thank you to read !
Here the alert log for the first connection of this morning :
Fri Jun 23 11:08:13 2017
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Picked latch-free SCN scheme 2
Using LOG_ARCHIVE_DEST_1 parameter default value as USE_DB_RECOVERY_FILE_DEST
Autotune of undo retention is turned on.
IMODE=BR
ILAT =167
LICENSE_MAX_USERS = 0
SYS auditing is disabled
Starting up:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options.
Using parameter settings in server-side spfile C:\ORACLE_32\PRODUCT\11.2.0\DBHOME_2\DATABASE\SPFILEORCL.ORA
System parameters with non-default values:
processes = 1000
sessions = 1524
memory_target = 1232M
control_files = "C:\ORACLE_32\ORADATA\ORCL\CONTROL01.CTL"
control_files = "C:\ORACLE_32\FLASH_RECOVERY_AREA\ORCL\CONTROL02.CTL"
db_block_size = 8192
compatible = "11.2.0.0.0"
db_recovery_file_dest = "C:\oracle_32\flash_recovery_area"
db_recovery_file_dest_size= 3852M
undo_tablespace = "UNDOTBS1"
remote_login_passwordfile= "EXCLUSIVE"
db_domain = ""
dispatchers = "(PROTOCOL=TCP) (SERVICE=orclXDB)"
local_listener = "LISTENER_ORCL"
audit_file_dest = "C:\ORACLE_32\ADMIN\ORCL\ADUMP"
audit_trail = "DB"
db_name = "orcl"
open_cursors = 300
diagnostic_dest = "C:\ORACLE_32"
Fri Jun 23 11:08:20 2017
PMON started with pid=2, OS id=2160
Fri Jun 23 11:08:20 2017
VKTM started with pid=3, OS id=2164 at elevated priority
VKTM running at (10)millisec precision with DBRM quantum (100)ms
Fri Jun 23 11:08:21 2017
GEN0 started with pid=4, OS id=2168
Fri Jun 23 11:08:21 2017
DIAG started with pid=5, OS id=2172
Fri Jun 23 11:08:21 2017
DBRM started with pid=6, OS id=2176
OER 7451 in Load Indicator : Error Code = OSD-04500: option indiquée interdite !
Fri Jun 23 11:08:21 2017
PSP0 started with pid=7, OS id=2180
Fri Jun 23 11:08:21 2017
DIA0 started with pid=8, OS id=2184
Fri Jun 23 11:08:21 2017
MMAN started with pid=9, OS id=2188
Fri Jun 23 11:08:21 2017
DBW0 started with pid=10, OS id=2192
Fri Jun 23 11:08:21 2017
LGWR started with pid=11, OS id=2196
Fri Jun 23 11:08:21 2017
CKPT started with pid=12, OS id=2200
Fri Jun 23 11:08:21 2017
SMON started with pid=13, OS id=2204
Fri Jun 23 11:08:21 2017
RECO started with pid=14, OS id=2208
Fri Jun 23 11:08:21 2017
MMON started with pid=15, OS id=2212
starting up 1 dispatcher(s) for network address '(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
Fri Jun 23 11:08:21 2017
MMNL started with pid=16, OS id=2216
starting up 1 shared server(s) ...
ORACLE_BASE from environment = C:\oracle_32
Fri Jun 23 11:08:22 2017
alter database mount exclusive
Successful mount of redo thread 1, with mount id 1475182246
Database mounted in Exclusive Mode
Lost write protection disabled
Completed: alter database mount exclusive
alter database open
Fri Jun 23 11:08:31 2017
Errors in file c:\oracle_32\diag\rdbms\orcl\orcl\trace\orcl_lgwr_2196.trc:
ORA-00338: log 3 of thread 1 is more recent than control file
ORA-00312: online log 3 thread 1: 'C:\ORACLE_32\ORADATA\ORCL\REDO03.LOG'
Errors in file c:\oracle_32\diag\rdbms\orcl\orcl\trace\orcl_lgwr_2196.trc:
ORA-00338: log 3 of thread 1 is more recent than control file
ORA-00312: online log 3 thread 1: 'C:\ORACLE_32\ORADATA\ORCL\REDO03.LOG'
Errors in file c:\oracle_32\diag\rdbms\orcl\orcl\trace\orcl_ora_2232.trc:
ORA-00338: fichier journal 1 du thread plus recent que le fichier de controle
ORA-00312: journal en ligne 3 thread 1 : 'C:\ORACLE_32\ORADATA\ORCL\REDO03.LOG'
USER (ospid: 2232): terminating the instance due to error 338
Fri Jun 23 11:08:34 2017
Instance terminated by USER, pid = 2232`
Did you check the alert log of the database? that could be a good place to start looking.
Also when logged as sysdba, did you try to start the database: startup ?
If yes, what is the error message if any?

Varnish VCL "Symbol not found: std.querysort"

I am copying some VCL rules from this handy template and running on the latest stable Varnish4. However this section of the VCL:
vcl 4.0;
sub vcl_init {
# ...
# Normalize query arguments
set req.url = std.querysort(req.url);
}
^
Returns this error:
-- Logs begin at Tue 2016-03-15 10:44:31 UTC, end at Tue 2016-03-15 13:02:10 UTC. --
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: Message from VCC-compiler:
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: Symbol not found: 'std.querysort' (expected type STRING_LIST):
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: ('/etc/varnish/test.vcl' Line 55 Pos 23)
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: set req.url = std.querysort(req.url);
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: ----------------------#############----------
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: Running VCC-compiler failed, exited with 2
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: VCL compilation failed
Should I include a mod or define std somehow?
Yes! I stumbled on the answer inside another answer. Adding import std; at the top of the script stopped the error.
vcl 4.0;
import std;
sub vcl_init {
# ...
# Normalize query arguments
set req.url = std.querysort(req.url);
}

Resources