@@ -58,7 +58,7 @@ def assemble_blame_info(_, __) -> int:
5858from codechecker_common .compatibility .multiprocessing import Pool
5959from codechecker_common .source_code_comment_handler import \
6060 SourceCodeCommentHandler
61- from codechecker_common .util import format_size , load_json
61+ from codechecker_common .util import format_size , load_json , strtobool
6262
6363from codechecker_web .shared import webserver_context , host_check
6464from codechecker_web .shared .env import get_default_workspace
@@ -964,51 +964,111 @@ def main(args):
964964 description = args .description if 'description' in args else None
965965
966966 LOG .info ("Storing results to the server ..." )
967- task_token : str = client .massStoreRunAsynchronous (
968- b64zip ,
969- SubmittedRunOptions (
970- runName = args .name ,
971- tag = args .tag if "tag" in args else None ,
972- version = str (context .version ),
973- force = "force" in args ,
974- trimPathPrefixes = trim_path_prefixes ,
975- description = description )
976- )
977- LOG .info ("Reports submitted to the server for processing." )
978-
979- if client .allowsStoringAnalysisStatistics ():
980- store_analysis_statistics (client , args .input , args .name )
981-
982- if "detach" in args :
983- LOG .warning ("Exiting the 'store' subcommand as '--detach' was "
984- "specified: not waiting for the result of the store "
985- "operation.\n "
986- "The server might not have finished processing "
987- "everything at this point, so do NOT rely on querying "
988- "the results just yet!\n "
989- "To await the completion of the processing later, "
990- "you can execute:\n \n "
991- "\t CodeChecker cmd serverside-tasks --token %s "
992- "--await" ,
993- task_token )
994- # Print the token to stdout as well, so scripts can use "--detach"
995- # meaningfully.
996- print (task_token )
997- return
998-
999- task_client = libclient .setup_task_client (protocol , host , port )
1000- task_status : str = await_task_termination (LOG , task_token ,
1001- task_api_client = task_client )
1002-
1003- if task_status == "COMPLETED" :
1004- LOG .info ("Storing the reports finished successfully." )
967+
968+ if strtobool (os .environ .get ('CC_FORCE_SYNC_STORE' , 'no' )):
969+ try :
970+ with _timeout_watchdog (timedelta (hours = 1 ),
971+ signal .SIGUSR1 ):
972+ client .massStoreRun (args .name ,
973+ args .tag if 'tag' in args else None ,
974+ str (context .version ),
975+ b64zip ,
976+ 'force' in args ,
977+ trim_path_prefixes ,
978+ description )
979+ except WatchdogError as we :
980+ LOG .warning ("%s" , str (we ))
981+
982+ # Showing parts of the exception stack is important here.
983+ # We **WANT** to see that the timeout happened during a wait on
984+ # Thrift reading from the TCP connection (something deep in the
985+ # Python library code at "sock.recv_into").
986+ import traceback
987+ _ , _ , tb = sys .exc_info ()
988+ frames = traceback .extract_tb (tb )
989+ first , last = frames [0 ], frames [- 2 ]
990+ formatted_frames = traceback .format_list ([first , last ])
991+ fmt_first , fmt_last = formatted_frames [0 ], formatted_frames [1 ]
992+ LOG .info ("Timeout was triggered during:\n %s" , fmt_first )
993+ LOG .info ("Timeout interrupted this low-level operation:\n %s" ,
994+ fmt_last )
995+
996+ LOG .error (
997+ "Timeout!"
998+ "\n \t The server's reply did not arrive after "
999+ "%d seconds (%s) elapsed since the server-side "
1000+ "processing began."
1001+ "\n \n \t This does *NOT* mean that there was an issue "
1002+ "with the run you were storing!"
1003+ "\n \t The server might still be processing the results..."
1004+ "\n \t However, it is more likely that the "
1005+ "server had already finished, but the client did not "
1006+ "receive a response."
1007+ "\n \t Usually, this is caused by the underlying TCP "
1008+ "connection failing to signal a low-level disconnect."
1009+ "\n \t Clients potentially hanging indefinitely in these "
1010+ "scenarios is an unfortunate and known issue."
1011+ "\n \t \t See http://github.com/Ericsson/codechecker/"
1012+ "issues/3672 for details!"
1013+ "\n \n \t This error here is a temporary measure to ensure "
1014+ "an infinite hang is replaced with a well-explained "
1015+ "timeout."
1016+ "\n \t A more proper solution will be implemented in a "
1017+ "subsequent version of CodeChecker." ,
1018+ we .timeout .total_seconds (), str (we .timeout ))
1019+ sys .exit (1 )
1020+
1021+ if client .allowsStoringAnalysisStatistics ():
1022+ store_analysis_statistics (client , args .input , args .name )
10051023 else :
1006- LOG .error ("Storing the reports failed! "
1007- "The job terminated in status '%s'. "
1008- "The comments associated with the failure are:\n \n %s" ,
1009- task_status ,
1010- task_client .getTaskInfo (task_token ).comments )
1011- sys .exit (1 )
1024+ task_token : str = client .massStoreRunAsynchronous (
1025+ b64zip ,
1026+ SubmittedRunOptions (
1027+ runName = args .name ,
1028+ tag = args .tag if "tag" in args else None ,
1029+ version = str (context .version ),
1030+ force = "force" in args ,
1031+ trimPathPrefixes = trim_path_prefixes ,
1032+ description = description )
1033+ )
1034+ LOG .info ("Reports submitted to the server for processing." )
1035+
1036+ if client .allowsStoringAnalysisStatistics ():
1037+ store_analysis_statistics (client , args .input , args .name )
1038+
1039+ if "detach" in args :
1040+ LOG .warning (
1041+ "Exiting the 'store' subcommand as '--detach' was "
1042+ "specified: not waiting for the result of the store "
1043+ "operation.\n "
1044+ "The server might not have finished processing "
1045+ "everything at this point, so do NOT rely on querying "
1046+ "the results just yet!\n "
1047+ "To await the completion of the processing later, "
1048+ "you can execute:\n \n "
1049+ "\t CodeChecker cmd serverside-tasks --token %s "
1050+ "--await" ,
1051+ task_token )
1052+ # Print the token to stdout as well, so scripts can use
1053+ # "--detach" meaningfully.
1054+ print (task_token )
1055+ return
1056+
1057+ task_client = libclient .setup_task_client (protocol , host , port )
1058+ task_status : str = await_task_termination (
1059+ LOG , task_token , task_api_client = task_client )
1060+
1061+ if task_status == "COMPLETED" :
1062+ LOG .info ("Storing the reports finished successfully." )
1063+ else :
1064+ LOG .error (
1065+ "Storing the reports failed! "
1066+ "The job terminated in status '%s'. "
1067+ "The comments associated with the failure are:\n \n %s" ,
1068+ task_status ,
1069+ task_client .getTaskInfo (task_token ).comments )
1070+ sys .exit (1 )
1071+
10121072 except Exception as ex :
10131073 import traceback
10141074 traceback .print_exc ()
0 commit comments