Debugging failures in production environments

First, I have to give you some context. This program is a fairly typical server application implemented in C ++. Through the project, as well as in all base libraries, error management is based on C ++ exceptions.

My question is related to the elimination of fatal errors and / or programmer errors --- the free equivalent of "unchecked" Java exceptions due to the lack of a better parallel. I am particularly interested in the common practices of dealing with such conditions in the production of environments.

For production environments, in particular, there are two conflicting goals in the presence of the above class of errors: ease of debugging and accessibility (in the sense of operational characteristics). Each of this, in turn, indicates a specific strategy:

  • Install a top-level exception handler to absorb all that are not displayed except to ensure continuous availability. Unfortunately, this makes error checking more attractive, forcing the programmer to rely on fine-grained logging or other code "test equipment" methods.

  • Failure as bad as possible; This allows an autopsy analysis of the state that led to the error through the dump core. Naturally, you need to provide funds to resume the system in a timely manner after an accident, and this can be far from trivial.

So, I end up with two semi-dried solutions; I would like to compromise between service availability and debugging tools. What am I missing?

. ++, , ; , , /.

+4
2

: OP , . , , , .

, ( ) :

  • ( )

, . .


++/Java try/catch , , try catch , . : Rust Go, , fail .

3 :

  • unrecoverable:
  • : (,...)
  • : , , .

. , (, ) . , ( ), . . Valgrind, Asan, Purify .. - , ; () , .

, , , . . , . ( ) .

, , , , . , , Production ( cookie, ).


. Mozilla rr, , , , . .

, . , , /.

() :

  • , , ,
  • ,

( ) . , ( bad_alloc... ).

, .

:

  • ( )
  • () ,
  • () /
  • , ,
  • , , ( , , ).

?

, I/O. , , . / : , , , , ( , ),...

, , ( ). , (: - , , , , , , ).

- . : std::out_of_range ( what): vector::_M_range_check libstd++ vector.

, , , vector , 3 640 , .

:

  • : "access to index 32 in vector of size 4" , ?
  • : , , !

: , , , ; ;)

, RAII: . , , , if , ( , ...).

, catch, try/catch, RAII .

: , std , , throw std::bad_alloc; std::bad_alloc, ( ). .

?

, , , (aka, exception).

, :

  • ,

, :

  • ( ) ; , , .
  • "" : ? ( ? ?...), ? ( ? ?...)
  • : /, !

​​ , , - , - . , , :

  • : / , ,
  • :
  • log-level driven: , , ,

/

N ; , -. , N !

, , , . , , ( ) ( ).

, " " /, , :)

( ) , ( ).

rr

20% , , rr . , , , 1 N rr .

A/B, ( ), .

, , , . 20%.


, , , . . , .

+1

, , . , . , " ", " " .., .

, ( ).

, , QA ( ) ( ), / .

, , , (.. , ..).

0

Source: https://habr.com/ru/post/1532511/


All Articles