On Ordering Problems in Message Passing Software

On Ordering Problems in Message Passing Software

On Ordering Problems in Message Passing Software Yuheng Long Mehdi Bagherzadeh Eric Lin Ganesha Upadhyaya Hridesh Rajan Iowa State University, USA {csgzlong,mbagherz,eylin,ganeshau,hridesh}@iastate.edu Abstract model. Use of Erlang [5] in the development of Amazon The need for concurrency in modern software is increas- Web Services and Akka [4] in the Guardian’s web site are ingly fulfilled by utilizing the message passing paradigm be- just a few examples of such interest. cause of its modularity and scalability. In the message pass- The message passing paradigm allows for modular devel- ing paradigm, concurrently running processes communicate opment [3, 26] and reasoning [6, 18, 27] of its programs. In by sending and receiving messages. Asynchronous messag- the message passing paradigm, a module (process) commu- ing introduces the possibility of message ordering problems: nicates with other concurrently running processes by send- two messages with a specific order in the program text could ing and receiving messages. For enhanced throughput, these take effect in the opposite order in the program execution and messages are usually sent asynchronously [3, 4]. However, lead to bugs that are hard to find and debug. We believe that asynchronous sending of messages introduces the possibil- the engineering of message passing software could be easier ity of ordering problems that we call the message ordering if more is known about the characteristics of message order- problem and makes development of message passing soft- ing problems in practice. In this work, we present an analysis ware difficult and error-prone. In an ordering problem, two to study and quantify the relation between ordering problems messages with a specific sequential order in the program text and semantics variations of their underlying message pass- could take effect in the opposite order in the program exe- ing paradigm in over 30 applications. Some of our findings cution. Previous work [12, 24, 30, 47] shows that ordering are as follows: (1) semantic variations of the message passing problems are prevalent and could lead to bugs that are hard paradigm can cause ordering problems exhibited by applica- to find and debug. A bug usually happens when a program- tions in different programming patterns to vary greatly; (2) mer, based on the program text, assumes a message order some semantic features such as in-order messaging are criti- which may not actually exist during the program execution. cal for reducing ordering problems; (3) modular enforcement 1 class Client extends Actor { 2 ActorName server; .. of aliasing in terms of data isolation allows small test con- 3 @message void start() { figurations to trigger the majority of ordering problems. 4 send(server, "set", 1);// async message send 5 int v = send(server, "get");// async message send Categories and Subject Descriptors D.1.3 [Programming 6 assert(v == 1);// assertion Φ 7 } .. Techniques]: Concurrent Programming — Distributed pro- 8 } gramming;D.3.3[Programming Languages]:Language Con- Figure 1: A message ordering problem happens when using structs and Features—Concurrent programming structures the program text, on lines 4–5, a programmer mistakenly Keywords Message passing, quantification of message or- assumes that the asynchronous message set is sent and dering problems, asynchronous messages processed before get, causing a real world bug [24]. To illustrate, Figure 1 – written in the message passing 1. Introduction programming language ActorFoundry [1] – shows a simpli- The concurrency revolution [45] has renewed interest in fied version of a real world bug [24] caused by a message or- the message passing paradigm [2] because of its modular dering problem. A Client process (actor), sends an asyn- [3, 6, 18, 26, 27] and scalable [48] concurrent programming chronous message set to a server process, on line 4, to set the value of a variable in the server to 1. Later, the client sends another asynchronous message get, on line 5, to read the value of the variable in the server. Because sending of the set message appears before sending of the get message in the program text, it is very likely [12, 24, 30, 47] that a sequentially-trained programmer assumes that the set mes- sage is sent and processed in the server before the get mes- [Copyright notice will appear here once ’preprint’ option is removed.] sage and therefore get reads the value 1 set by set and the assertion Φ holds; and this is exactly what the programmer To further illustrate semantic tuning, Akka configurations assumes in this example [24, 47]. However, the execution of allow a programmer to configure and run a program with the program could surprise the programmer by causing a bug either asynchronous or synchronous messaging for C1. For and violation of Φ. This is because, depending on the mes- C2, ActorFoundry and HAL constraints [19] allow config- saging semantics of ActorFoundry, set and get messages urations of both nondeterministic and in-order message de- could during program execution be received and processed livery and processing. For C3, Kilim annotations [43] allow by the server in an order which is the opposite of their ap- configurations for both data sharing and isolation. pearance order in the program text in the client. This in turn 1.1.2 Semantic Diversity in Multiple Paradigms causes the get message to return a value that may not be There are several message passing programming languages equal to 1 and therefore cause a bug and violate Φ. This bug and frameworks available with different semantics for C1– happens because, based on the program text, the programmer C3. Such semantic diversity could make it difficult to un- mistakenly assumes an ordering (in-order delivery and pro- derstand and avoid message ordering problems, especially cessing) between set and get messages that may not exist when a program with no ordering problems in one paradigm during the program execution, depending on the semantics may suffer from ordering problems in another paradigm [39] of the message send operation. and vice versa. For example, deprecation of Scala Actor [17] 1.1 Root Causes of Message Ordering Problems message passing paradigm and its evolution into Akka may We believe that the semantic variations of the following 3 require a programmer to migrate their program from Scala criteria in the message passing paradigm are the root causes Actor to Akka with cautionary warnings like: of message ordering problems: “Due to differences between the two actor implementations it is possible that errors appear. It is recommended to thoroughly test • C1: Message synchronization semantics, categorized into the code after each step of the migration process.” — The Scala asynchronous and synchronous messaging [22]. Actors Migration Guide [39] • C2: Message processing semantics, categorized into non- There is no guarantee that a program in Scala Actor with deterministic and in-order delivery and processing. no ordering problems will have no ordering problems when migrated to Akka. • C3: Sharing semantics, categorized into data sharing and To illustrate the semantic diversity, Scala [16] and Panini data isolation of memory effects between processes. [37, 38] support both asynchronous and synchronous mes- In addition to semantic variations of C1–C3, two other fac- saging for C1 whereas Erlang [5] and standard actor tors could make it harder for a programmer to understand model only support asynchronous messaging. For C2, Ac- and avoid message ordering problems: (1) semantic tuning torFoundry messages are delivered and could be processed of the underlying message passing paradigm of a single pro- nondeterministically whereas Akka and JCoBox [40] sup- gram and (2) diversity of semantic variations that are avail- port in-order delivery and processing. For C3, the standard able for the message passing paradigm. actor model supports data isolation between processes, Scala 1.1.1 Semantic Tuning in a Single Paradigm allows sharing and ActorFoundry supports both. 1.2 Understanding Message Ordering Problems There are message passing languages and frameworks, such as Akka [4], that allow the programmer to configure vari- On the one hand, the concurrency revolution requires ous semantics for C1–C3 in the underlying message passing sequentially-trained programmers that mostly think sequen- paradigm of a single program. Such semantic tuning could tially [30] to write concurrent programs in the message make message ordering problems harder to understand and passing paradigm, which is a modular concurrent program- avoid: a program that is free from message ordering prob- ming model with increasing popularity. On the other hand, lems in one configuration may suffer from ordering prob- the message ordering problems make programming in this lems in another configuration. paradigm difficult and error-prone [24, 47] for these pro- For example, suppose the code in Figure 1 was written grammers [30, 45]. We believe that the engineering of mes- in Akka instead of ActorFoundry. Akka allows the program- sage passing software could be easier if we know more about mer to configure the message synchronization semantics of the characteristics of message ordering problems in practice. send and to change it from the default asynchronous messag- This makes it critical to study and understand the relation be- ing to synchronous. Such configuration of message synchro- tween the semantics of a message passing paradigm and the nization semantics takes original program with a message ordering problems

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us