You are on page 1of 51

Distributed Systems.

Concurrency and
Consistency 1st Edition Edition
Matthieu Perrin (Auth.)
Visit to download the full and correct content document:
https://ebookmass.com/product/distributed-systems-concurrency-and-consistency-1st
-edition-edition-matthieu-perrin-auth/
Distributed Systems
Series Editor
Jean-Charles Pomerol

Distributed Systems

Concurrency and Consistency

Matthieu Perrin
First published 2017 in Great Britain and the United States by ISTE Press Ltd and Elsevier Ltd

Apart from any fair dealing for the purposes of research or private study, or criticism or review, as
permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced,
stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers,
or in the case of reprographic reproduction in accordance with the terms and licenses issued by the
CLA. Enquiries concerning reproduction outside these terms should be sent to the publishers at the
undermentioned address:

ISTE Press Ltd Elsevier Ltd


27-37 St George’s Road The Boulevard, Langford Lane
London SW19 4EU Kidlington, Oxford, OX5 1GB
UK UK
www.iste.co.uk www.elsevier.com

Notices
Knowledge and best practice in this field are constantly changing. As new research and experience
broaden our understanding, changes in research methods, professional practices, or medical treatment
may become necessary.

Practitioners and researchers must always rely on their own experience and knowledge in evaluating and
using any information, methods, compounds, or experiments described herein. In using such information
or methods they should be mindful of their own safety and the safety of others, including parties for
whom they have a professional responsibility.

To the fullest extent of the law, neither the Publisher nor the authors, contributors, or editors, assume any
liability for any injury and/or damage to persons or property as a matter of products liability, negligence
or otherwise, or from any use or operation of any methods, products, instructions, or ideas contained in
the material herein.

For information on all our publications visit our website at http://store.elsevier.com/

© ISTE Press Ltd 2017


The rights of Matthieu Perrin to be identified as the author of this work have been asserted by him in
accordance with the Copyright, Designs and Patents Act 1988.

British Library Cataloguing-in-Publication Data


A CIP record for this book is available from the British Library
Library of Congress Cataloging in Publication Data
A catalog record for this book is available from the Library of Congress
ISBN 978-1-78548-226-7

Printed and bound in the UK and US


Acknowledgments

I am grateful to Achour Mostéfaoui and Claude Jard for their contribution to the
work presented in this book. I offer warm thanks to Luc Bougé and Maria
Potop-Butucaru for their relevant comments that helped improve the quality of this
book. Finally, I would like to thank Matoula Petrolia for playing Alice’s role in the
illustrating examples.
Introduction

I.1. Preamble

Bob was daydreaming as he walked into the subway station. It has been two days
since he had last talked to Alice. His anger has gradually turned into bitterness, then
into guilt. He understood now that his initial reaction had been somewhat
exaggerated and wanted more than anything to bury the hatchet with his childhood
friend but did not know how to approach the situation. He felt surprised and relieved
when he received a message from her inviting him to go out for coffee. He managed
to quickly respond as the train was approaching the dark tunnel. However, at the heart
of the city, the failing network could not transmit his liberating reply “Obviously”.

Alice loved Bob as a sister, despite the chronic anxiety and shady character of the
one whom she saw as her oldest friend. Two days earlier, he had left in a rage because
of a simple misunderstanding and she hadn’t been able to reason with him since. Even
now, reconciliation seemed difficult: Bob had purely and simply ignored her invitation
to go out for coffee. She tried a new strategy and sent “You didn’t answer.” followed a
few seconds later by a humble “Are you angry?”.

The story does not tell what happened in the end and we can only imagine
it. As strange as it may seem, Alice and Bob’s fate very strongly depends on
the instant messaging service chosen to communicate. We have tried to reproduce
their conversation with three general instant messaging services: Google Hangouts1
(Hangouts), WhatsApp Messenger2 (WhatsApp) and Microsoft Skype3 (Skype). The
experiment has been performed with Matoula Petrolia playing the role of Alice and
myself in the role of Bob. Bob’s dropping connection has been modeled by using the

1 http://www.hangouts.google.com/
2 http://www.whatsapp.com/
3 http://www.skype.com/
xii Distributed Systems

airplane mode of the mobile phone. For each experiment, we present a screenshot
taken before reconnection and another taken after reconnection for both interlocutors.
The three messaging services exhibit very different behaviors confronted with the
same situation.
Hangouts (Figure I.1). Bob received Alice’s messages when coming out of the
subway. He looked absently at them thinking to himself that his own message should
have taken some time to reach her. It was not until late in the afternoon, when he was
about to specify the time and place of the meeting that he noticed the error message
written in small prints underneath her answer: “Message not sent. Touch to retry.”. He
resigned to call Alice to straighten things out.
WhatsApp (Figure I.2). Bob’s response felt to Alice like a cold shower.
“Obviously!” Not only he was angry at her but he has had no problems in saying it
out loud and as sarcastically as possible. Bob asked her later at what time she wanted
to see him. She did not immediately understand but seized the opportunity to accept.
It was only in the evening, when Bob showed her his own thread of messages that
she understood what had happened: their messages had been mixed up and each had
received the message from the other only after having sent their own. As a result, Bob
couldn’t have known that she had misinterpreted his message.
Skype (Figure I.3). Alice’s second strategy was also as unsuccessful as the first.
Although she was regularly checking her phone the whole day long, there was no
message from Bob arriving after her own on her thread of messages. She felt stupid
when she finally realized her mistake: she had not seen the cheerful response that Bob
had sent her before she sent him her second message. She hastened to apologize and
to make another meeting with Bob.

Based on these three scenarios, it can be seen that compromises are inevitable
when temporary disconnections happen, be it an error message (Hangouts), a
reordering of messages (Skype) or a presentation of a different state to the
interlocutors (WhatsApp). Each strategy has its own qualities but none is without
flaw. Instant messaging services are intended to be used by human beings, capable of
adapting themselves to numerous situations. Programs, for their part, are much less
able to do so and the consequences of unexpected inconsistencies in the data shared
by computers can be much more serious. Disposing of an effective way to precisely
model the different types of inconsistency that can occur is therefore a very important
challenge.

I.2. Distributed systems and concurrency

D EFINITION I.1.– A distributed system is a collection of autonomous computing


entities connected to accomplish a joint task.

Detailed below are the three elements important to this definition.


Introduction xiii

Send("coffee break?") • H ANGOUTS


S ERIALIZABILITY

• Send("obviously")

Send("you did not answer") •

Send("are you still angry? ") •


Alice’s application (Matoula) Bob’s application (Matthieu)

Figure I.1. Behavior of Google Hangouts after disconnection


xiv Distributed Systems

Send("coffee break?") • W HATS A PP


P IPELINED CONSISTENCY

• Send("obviously")

Send("you did not answer") •

Send("are you still angry?") •


Alice’s application (Matoula) Bob’s application (Matthieu)

Figure I.2. Behavior of WhatsApp Messenger after disconnection


Introduction xv

Send("coffee break?") • S KYPE


S TRONG UPDATE
CONSISTENCY

• Send("obviously")

Send("you did not answer") •

Send("are you still angry?") •


Alice’s application (Matoula) Bob’s application (Matthieu)

Figure I.3. Microsoft Skype’s behavior after disconnection


xvi Distributed Systems

Computational entity. Computational entity refers to entities sufficiently


complex and able to make their own choices, either following their own will, such
as human beings or even animals, or based on the result of a complex computation
when it comes to processes on a computer, or even in response to external stimuli in
the case of sensor networks. The term process will be generically used to designate
these computational entities, even in situations where they do not correspond to the
execution of a program by a computer.
In the previous examples, Alice and Bob are two computational entities.
Conversely, a stellar system consisting of a star and several planets will not be
considered as a distributed system, because no entity comprised therein is capable
of decision-making.
Connection in view of performing a joint task. In order to qualify as a
distributed system, processes must have a need to communicate. For example, two
processes running different programs on the same computer (such as a music player
and a text editor) do not have a joint task to accomplish. Conversely, in the previous
example, Alice and Bob are seeking to solve a dispute, which forms their joint task.
To this end, they use a messenger service that allows them to connect together.
Note that the execution of a joint task does not necessarily mean that processes
share a common interest. There are many purposes for distributed systems. They
can be designed for the purpose of collaboration (document editing, Web sites
administration, etc.) or instead for competition (network games, high-frequency
trading in financial markets, etc.) or even for simple communication (messaging
services, websites, peer-to-peer file sharing) between independent entities, generally
human. Finally, replication can be used to overcome failures: if a machine suffers
break down, others are available to substitute it.
Autonomy. In the previous examples, Alice and Bob are pre-existing in the
system. They existed before seeking to communicate and they will still exist after.
In the analysis of distributed systems, the focus is on issues that may occur with
processes to accomplish their joint task. The fact that they are autonomous means
that their operation depends only on themselves. In particular, there can be no master
process among them that decides when and how others can operate. The autonomy of
processes is what differentiates distributed systems and parallel systems. In a parallel
system, the objective is to aggregate computing power to accomplish a particularly
complex task, such as the simulation of physical or biological phenomena. The
program executed by the processes is known in advance, and its execution is supposed
to depend only on initial parameters. However, a parallel system can implement
techniques proper to distributed systems, especially to synchronize processes. The
difference between parallel and distributed systems is therefore more a matter of point
of view than a reality of the system. This distinction between parallel and distributed
computing is detailed by Michel Raynal in [RAY 15].
Introduction xvii

The world that surrounds us is inherently a distributed system composed of


independent individuals forced to communicate in their daily tasks to elect their
representatives, to avoid collisions on the road, etc. Specifically, distributed computer
systems, in which the behavior of processes is governed by controllable programs,
have recently invaded our lives. In 2015, over three billion internauts were recorded
throughout the world4, today any processor in a mobile phone is multi-core, cloud
computing is starting to become more democratic with the expansion of the services
it offers and geo-replication is widely used to ensure the persistence of sensitive data.

Despite all possible applications of distributed systems, distributed applications


are generally much harder to design than their sequential counterparts: while events
in a sequential environment occur one after another in a sequence controlled by the
programmer, the notion of time between events occurring in a distributed system
appears to be much more blurred. In Alice and Bob’s example, it is not clear if Alice
has sent her last two messages before or after Bob, hence the differences in behaviors
observed in this situation for the three instant messaging services. This situation,
proper to distributed systems, in which events are not totally ordered has a name:
concurrency.

D EFINITION I.2.– A system is said to be concurrent if its behavior depends on the


order in which operate the actors of the system.

I.3. Wait-free distributed systems

The mastering of concurrency is one of the main challenges in distributed systems.


According to the security level required for applications and the control of incidents
likely to occur in the system in which they are deployed, concurrency will be more
or less visible. For example, in the control system of a plane, the relative speed of
each component and the paths taken by control orders are perfectly under control so
as to remove any uncertainty associated with concurrency. In contrast, in collaborative
document editors such as subversion or git, the majority of editing events are carried
out offline. Concurrency is then detected at the time of synchronization, resulting
in conflicts that must be manually solved. The main parameters that characterize a
distributed system are listed here below.
System scale. A system is distributed when it comprises at least two processes.
Therefore, a program whose graphical interface (GUI) is displayed on the screen in
an asynchronous fashion can already be considered as distributed. In contrast, Tianhe-
2, currently the most powerful supercomputer in the world, has 3,120,000 cores and
BOINC, the management platform of the peer-to-peer project SETI@home [SPA 99]
dedicated to the research of extra-terrestrial signals, claims to be installed on more
than thirteen million computers in the world5.

4 http://www.internetlivestats.com/watch/internet-users/
5 http://boincstats.com
xviii Distributed Systems

Interaction means. In general, we can make a distinction between systems


in which processes must communicate by exchanging messages and those in which
processes access shared memory. Finer divisions can bring further detail into these
families. If processes communicate by messages, is the network complete? Do
processes know their neighbors? Are these fixed? Can they choose their neighbors?
For those communicating by means of shared memory, what operations are they
allowed to call? Can they write to all registers?
Failure management. The greater the systems, the more frequent failures are.
In peer-to-peer systems, processes leave and others connect to one another on a
permanent basis; when one considers the Internet as being increasingly composed of
connected mobile terminals, the reliability of transmissions cannot be assured; hackers
will always seek to attack sensitive applications such as those pertaining to banking
and governmental institutions (the so-called Byzantine faults). These faults can be of
various kinds: crash failure (a process stops its execution without warning others),
omission failure or loss of messages (when sending or receiving) or non-compliant
process behavior (memory corruption or intentional attacks). The number of failures
that can be accepted and the presence of a reliable server known to all are also defining
the characteristics of the system.
Relation to time. The presence or lack of a global clock accessible by all
processes, completely changes the nature of a system. In a fully synchronous system,
all processes proceed according to a well-defined temporal pattern (eventually a
priori) and if they communicate through messages, these messages are transmitted
within a limited timeframe. These two assumptions can be impaired. In a completely
asynchronous system, there is no bound on the relative speed of processes or on the
duration of message transfers (network latency). If, in addition, crash failures can
occur, a process that does not receive an expected message is unable to deduce if the
transmitter is faulty or extremely slow. The heterogeneity of the hardware running the
processes can be a major cause of asynchronicity.

The purpose of this book is to study concurrency. We are therefore considering


a poorly performing system where applications cannot hide it completely. For
example, it could be accepted, as in the preface, that processes undergo temporary
disconnections. More specifically, we assume that processes communicate by sending
messages to one another but that it is not acceptable nor possible for a process to wait
explicitly for messages from an another process. This assumption is realistic to model
a large number of systems, including those mentioned below.
Size. Systems whose number of processes is unknown, which prevent knowing
the number of responses to expect, in peer-to-peer systems, for instance.
Cost. Systems for which time spent waiting is considered too costly, for example
in high-performance computing.
Introduction xix

Partitions. Systems in which partitions can occur, temporarily preventing


processes to communicate with each other. Such partitions are frequent in cloud
architectures [VOG 09]. Temporary disconnections on the Internet can also be
modeled by partitions.
Faults. Systems for which fault management is critical to the extent where the
system should continue to operate even if only a single process is left operating in the
system. In such a situation, a process cannot wait for the participation of a known a
priori number of other processes as they may be at fault. This case is the one that we
prefer to model the hypothesis in which there is no waiting time because it is easier to
formally define.

More precisely, we consider wait-free message-passing asynchronous distributed


systems. We only provide the intuition here, these systems being formally defined in
section 1.3.2.
Distributed message-passing systems. The systems that we consider are
composed of a fixed and known-sized set of sequential processes that communicate
by means of primitives for sending and receiving messages.
Wait-free systems. All processes are likely to crash and the system must
continue to operate even when reduced to a single process.
Asynchronous systems. Processes do not run at the same speed and there is no
bound on the time taken by a message to reach its destination. Under these conditions,
a process that does not receive a message that it is expecting can never know if this
message is very slow to reach it, or if the message has never been sent because of
failure in the transmitter.

I.4. Shared objects

At a very high level, distributed applications all share a similar model: processes
interact with each other by means of one or more shared objects that are able to
manage concurrency. In the case of an online game, the shared object is the game
being played and the rules of the game make explicit authorized strokes; processes
that compute weather forecasts share the map during the simulation, etc. Shared
memory and communication channels are other examples of shared objects, but at a
lower level. In general, distributed applications can often be modeled by layers, each
layer being an abstraction in the form of shared objects of the previous layer. To sum
up, a program can be seen as a hierarchy of shared objects, each with its level of
semantic requirement.

For instance, consider a collaborative editing of documents. At the highest level,


the application provides access to character insert and delete operations at the cursor
level and cursor movement operations, accessible from the keyboard. The
xx Distributed Systems

implementation of these operations involves a data structure that stores the sequence
of characters of the document. Depending on the application, this sequence itself
utilizes lower-level objects, such as a data management system abstracting the
communication primitives of the system in which the application is implemented.

The fact of considering a perspective that involves wait-free systems has significant
implications for the shared objects that can be build therein [ATT 95, ATT 94]. When
an operation on a shared object is initiated at the local level by a process, it must
be processed using only local knowledge of the process. The reads should be effected
locally, which means that each process has a local copy of the object. The impossibility
of synchronizing during operations prevents the removal of all inconsistencies. These
must therefore be specified with special attention. The central question of this book
can be formulated in this way: how can shared objects be specified in a wait-free
system?

I.5. Shared object specification

How can we describe what an instant messaging service is? If we ask the
question randomly to users of these services, odds are high that the answer will be as
follows. “An instant messaging service allows the sending of messages between
multiple correspondents and displays received messages, from the oldest to the
newest”. This describes the normal behavior of these services, which occurs when
there is no concurrency occurring, i.e. in the case of sequential use. In the same way,
developers of concurrent applications in general often wish they could make use of a
shared version of the objects they are accustomed to in sequential programs. The
specification of a shared object must therefore rely on its sequential specification.

Obviously, the sequential specification is insufficient to explain the differences


between the three services exposed in the prologue. One additional property,
consistency criterion, is necessary to explain how concurrency is managed. During
concurrent execution, accesses to shared objects create interactions between the local
operations of the various processes. Figure I.4 shows some examples of histories
extracted from concurrent executions involving one or two processes sharing a set
inside which it is possible to insert values or whose content can be read, i.e. the set of
the values previously inserted. The figure shows the operations performed by each
process over time, which elapses from the left to the right. A rounded rectangle
defines the time between the call and the return of an operation. The values returned
by the reads are represented after a slash.

Which histories are correct? In the sequential case, there is no possible ambiguity.
In Figure 1.4(a), during its first read, the process has inserted 1, it can therefore
return only {1}. The reads following the insertion of the 2 have no other option than
returning {1, 2}. The history of Figure 1.4(b) must also be considered as correct: all
Introduction xxi

operations are consecutive in time and the sequence of values returned is the same as
in the sequential execution. What about Figure 1.4(c)? The operations are also
sequential but the first read follows the insertion of the 2 without taking it into
account. On the one hand, we could argue that this reading is false and therefore that
this history is inconsistent. On the other hand, each process performs the same
operations and reads the same values as in the previous execution. The only
difference between these two histories is thus how both processes perceive their
relative speed [PER 16]. However, in an asynchronous system, processes are unable
to tell the difference between the two histories, because the observed temporal order
could also be due to a desynchronization of the clocks of both processes, which
would have no effect on programs that use the object. There is therefore no definitive
answer to what is a consistent history, every situation being simply better described
by a particular consistency criterion. History of Figure I.4(b) is said to be
linearizable whereas that of Figure I.4(c) is only sequentially consistent.

p Insert(1) Read()/{1} Insert(2) Read()/{1, 2} Read()/{1, 2}

(a) Sequential execution

p1 Insert(1) Read()/{1} Read()/{1, 2}

p2 Insert(2) Read()/{1, 2}

(b) Linearizable execution

p1 Insert(1) Read()/{1} Read()/{1, 2}

p2 Insert(2) Read()/{1, 2}

(c) Sequentially consistent execution

p1 Insert(1) Read()/{1} Read()/{1, 2}

p2 Insert(2) Read()/{2} Read()/{1, 2}

(d) Causally convergent execution

Figure I.4. Which behaviors are acceptable?

Unfortunately, sequential consistency and linearizability are too strong criteria to


be implemented in wait-free systems [ATT 94, GIL 02]: inconsistencies such as those
of history in Figure 4(d) cannot be avoided. In this case, how can we describe such
histories? The literature related to the subject presents a limited picture of the concepts
and definitions, often partial and incomparable between themselves. The extension
xxii Distributed Systems

and the formalization of these concepts is an important part of the work presented in
this book. We endeavor to fill in the blanks in order to extract the structure of the space
of weak criteria and therefrom to draw a map presented in Figure I.5.

I.6. Organization

After this introduction, a notation table is provided. Next, Chapter 1 presents the
mathematical framework common to all other chapters: therein we formally define
sequential specifications, concurrent histories and consistency criteria. This chapter
also formally defines wait-free systems.

In Chapter 2, we present the key concepts proposed by the various communities


facing concurrency to specify their distributed objects. As much as possible, we try
to include these concepts in the context presented in the previous chapter with the
objective to compare them. The most difficult concepts to expand will be the subject
to the following chapters.

Eventual consistency requires that all processes terminate in a common


convergence state. The specification of this convergence state is a difficult problem.
In Chapter 3, we present two consistency criteria to solve it: update consistency and
strong update consistency that relate the convergence state to updates by means of
the sequential specification. Therein, we also present three algorithms to implement
them in wait-free systems.

Causal memory [AHA 95] is recognized as a central object among the memory
models that can be implemented in wait-free systems, but its definition utilizes
semantic links between reads and writes. Chapter 4 addresses the challenge of
including causality as a consistency criterion in our model. We define therein four
consistency criteria. Weak causal consistency is the greatest common denominator of
these four criteria. It can be associated with update consistency to form causal
convergence or to pipelined consistency to form causal consistency, which
corresponds to causal memory when it is applied to memory. Strong causal
consistency finally enables the study of false causality induced by the standard
implementation of causal memory.

Chapter 5 focuses on computability in wait-free systems. In this chapter, we


establish a structural map of the space of weak criteria, divided into three families of
primary criteria (eventual consistency, validity and state locality) which can be
combined in pairs to form three families of secondary criteria (update consistency,
pipelined consistency and serializability). On the other hand, the conjunction of the
three primary criteria cannot be implemented in wait-free systems, which justifies the
colors of Figure I.5.
Introduction xxiii

Chapter 6 shows how these concepts can be applied to programming for


distributed systems. The library CODS implements weak consistency criteria within
the object-oriented programming language D. CODS offers the most possible
transparent abstract programming interface, in which instantiation is only replaced by
the reference to a sequential specification defined by a class of the program and of a
consistency criterion among those of the library or even implemented as an extension
of this library.
EC

SEC

C⊥ C⊥
UC
Ser
SC  CCv
SUC

SC
LC C

WCC
SL SCC V
CC

PC
C⊥

PC SEC SUC CCv WCC SCC


Pipelined Strong eventual Strong update Causal Weak causal Strong causal
consistency consistency consistency convergence consistency consistency
(p. 74) (p. 67) (p. 92) (p. 132) (p. 130) (p. 138)

SL EC UC Ser V CC
State Eventual Update Causal
locality consistency consistency Serializability Validity consistency
(p. 147) (p. 65) (p. 90) (p. 63) (p. 146) (p. 135)

 C⊥ C
SC LC SC
Sequential Local Cache Minimal Maximal
consistency consistency consistency criterion criterion
(p. 55) (p. 47) (p. 43) (p. 42) (p. 42)

Figure I.5. Map of the consistency criteria discussed in this book. For
the color version of this figure, www.iste.co.uk/perrin/distributed.zip
xxiv Distributed Systems

Finally, Chapter 6 summarizes the previous chapters and outlines future


directions for research. After the bibliography, the index provides help to navigate the
document.
List of Notations

Mathematical notations

E → F
f: Function f that maps f (x) ∈ F to each x ∈ E
x → f (x)
P(E) Power set of E
P<∞ (E) Set of subsets of finite cardinality of E
EF Disjoint union of E and F
f |E Restriction of f to E (f : function, E: set)
e≺ Predecessors of e in ≺ (≺⊂ E 2 : acyclic relation, e ∈ E)
e ≺ Successors of e in ≺ (≺⊂ E 2 : acyclic relation, e ∈ E)

≺ Transitive closure of ≺ (≺⊂ E 2 : relation)

Σ Set of finite words on Σ (Σ: alphabet)
Σω Set of infinite words on Σ (Σ: alphabet)
Σ∞ Σ∞ = Σ ∪ Σω (Σ: alphabet)
|u| Length of u (u ∈ Σ )
ε Word of length 0
u·v Concatenation of u and v (u ∈ Σ , v ∈ Σ∞ )
[a − z] Set of the letters in the Latin alphabet

Abstract data types

ADT Abstract data type


UQ-ADT Update-query abstract data type
CADT Commutative abstract data type
T Set of all ADTs
TU Q Set of all UQ-ADTs
A (read Alpha) Input alphabet
xxvi Distributed Systems

B (read Beta) Output alphabet


Z (read Zeta) Set of abstract states
ζ0 Initial state
τ Transition function
δ Output function
Σ Set of operations
τT Transition function for the operations (T ∈ T )
δT−1 Possible states for the operations (T ∈ T )
UT Set of update operations of T (T ∈ T )
QT Set of query operations of T (T ∈ T )
ÛT Set of pure update operations of T (T ∈ T )
Q̂T Set of pure query operations of T (T ∈ T )
L(T ) Sequential specification of T (T ∈ T )
T × T Composition of T and T  (T, T  ∈ T )
Mx Register x (x: register name)
MX Memory on X (X: set of register names)
SVal Set of support Val (Val : set of values)
QX Queue ADT on X (X: set of values)
QX Queue UQ-ADT on X (X: set of values)
Wk Sliding window register of size k (k ∈ N)

Concurrent histories

H Concurrent histories
lin(H) Linearizations of H (H ∈ H)
EH Events of H (H ∈ H)
UT,H Update events of H (T ∈ T , H ∈ H)
QT,H Query events of H (T ∈ T , H ∈ H)
ÛT,H Pure update events of H (T ∈ T , H ∈ H)
Q̂T,H Pure query events of H (T ∈ T , H ∈ H)
e → e Process order (e, e ∈ EH )
e −−→ e Visibility relation (e, e ∈ EH )
VIS

V is(H) Set of visibility relations of H (H ∈ H)


e ≤ e Total order (e, e ∈ EH )
e  e Causal order (e, e ∈ EH )
co(H) Set of causal orders (H ∈ H)
Σ Set of operations
Λ Labeling function
H  [A/B] Projection (H ∈ H,  ∈ (EH )2 , A, B ⊂ EH )
PH Maximal chains of H (H ∈ H)
ASn [ϕ] Asynchronous message-passing system (n: number of
processes, ϕ: condition on the faults)
List of Notations xxvii

Consistency criteria

C Set of consistency criteria


CW Set of weak criteria
CS Set of strong criteria
C1 ≤ C 2 C2 is stronger than C1 (C1 , C2 ∈ C)
C 1 + C2 Upper bound of C1 and C2 (C1 , C2 ∈ C)
C1 C2 Lower bound of C1 and C2 (C1 , C2 ∈ C)
C(T, T  ) Composition of shared objects (C ∈ C, T, T  ∈ T )
C Maximal criterion
C⊥ Minimal criterion
C Composition closure of C (C ∈ C)
SC Sequential consistency
PC Pipelined consistency
LC Local consistency
Ser Serializability
V Validity
SL State locality
EC Eventual consistency
SEC Strong eventual consistency
UC Update consistency
SUC Strong update consistency
WCC Weak causal consistency
CC Causal consistency
SCC Strong causal consistency
CCv Causal convergence
1

Specification of Shared Objects

1.1. Introduction

When a project manager designs the general architecture of an application, one of


his main concerns is to divide the workload into distinct logical entities, software
building blocks, thus enabling them to be implemented by different developers.
Each software building block is then separately specified to mitigate the risks of
conflict during the final integration. The specification is thus the communication vector
between two developers: the designer who designs the object and the user who uses
it in his/her own program. When the object in question is part of a library (and all the
more when the source code is proprietary), this is the only way to describe the object.
A good specification should be written from the user’s perspective and for the user.
We will now describe the three main qualities that a specification must have.
Rigor. A specification should not necessarily be an accurate characterization
of all the possible reactions of the object. In general, it instead concerns properties
verified in all situations. The proper level of detail must be adopted: properties that
are too strong excessively constrain the implementation, but too weak constraints only
partially depict the semantics of the object. On the other hand, all properties must be
perfectly mathematically defined to not give room for subjective interpretation. This
is especially true if formal validation techniques are being utilized.
Abstraction. One way to describe the behavior of an object in a rigorous way is
to give away its source code. This, however, does not make a good specification. As a
matter of fact, code modifications may be necessary in order to improve the efficiency
for solving errors, or adapt to a new environment. In all these cases, if the semantics
remain the same, there is no reason to change the specification. A specification should
be independent of the implementation. For a shared object, the values stored in the
local memory of a process and the messages sent, among others, should not be part of
the specification.
2 Distributed Systems

Simplicity. A specification provides a high level of abstraction to the user of


the software building block. What is desirable for the user who makes use of a stack-
based data structure is that the value that is popped out be always the last stacked
value that has not yet been popped out. Whether or not the implementation uses arrays
or linked lists is indifferent. A human user must therefore be able to understand as
quickly as possible what the function of the software building block is by only reading
its specification, hence the importance of the specification being designed from the
developer’s perspective who makes use of the object.

For designers, the specification is a goal to be attained, rather than just a way to
describe what they have managed to achieve (in the other case, this is instead referred
to as modeling). The specification is therefore a top-down process: users declare what
they require and designers implement what is requested from them. A high-level
programming language is an example of a specification method, in which users are
the programmers and the designers’ role is achieved by the compiler. In the best case,
a good specification system can similarly result in a programming language: we will
see in Chapter 6 how the concepts presented in this chapter can be integrated within a
modern programming language.

Problem. How can shared objects be specified?

Specifying a shared object is equivalent to defining which executions are possible


and which are not. A specification is thus a set of concurrent histories that model the
operations allowed by the object. However, a direct description of a set of histories is
hardly a reflection of the intuition that one makes of an object. In [SHA 11c], Shavit
clearly summarized how shared objects should be specified according to his point of
view: “It is infinitely easier and more intuitive for us humans to specify how abstract
data structures behave in a sequential setting, where there are no interleavings. Thus,
the standard approach to arguing the safety properties of a concurrent data structure is
to specify the structure’s properties sequentially, and find a way to map its concurrent
executions to these ‘correct’ sequential ones.”

Approach. In this chapter, we define a framework whereby the specification


of shared objects is separated into two distinct and complementary facets: a
sequential specification which describes the functional aspects of the object and
a consistency criterion which describes how concurrency affects its behavior.

The sequential specification describes functional aspects of the object without


taking into account the constraints related to concurrency. In the case of instant
messaging services (whether it be Hangouts, WhatsApp or Skype), the sequential
specification simply describes the fact that messages are displayed in the order they
are sent. Here, we describe this specification by means of a formal language
Specification of Shared Objects 3

recognized by a transition system, the abstract data type. The consistency criterion is
a function that transforms sequential specifications into sets of concurrent histories
admitted by the shared object. A concurrent history is the modeling of the execution
of a program on a given distributed system, which describes the computational
entities and their calls to the operations of the object that we aim to specify. It
assumes the form of a set of events partially ordered by a process ordering that
describes the sequentiality of the computational entities of the system. In this chapter,
apart from in section 1.3.2, we assume that the modeling of the distributed system
employing the concurrent stories has already been achieved.

This chapter is organized into three main parts. Section 1.2 presents the concepts
of abstract data types and sequential specifications. Then, section 1.3 addresses
concurrent histories and more precisely defines wait-free distributed systems. Finally,
the focus of section 1.4 is on the notion of consistency criterion.

1.2. Sequential specifications

The sequential specification of an object describes its behavior when it is


executed within a sequential environment (in other words, when it is used only by a
single process). The works that focus on the specification of data types are
tantamount to those describing the properties of formal languages and automata. We
also use transition systems to specify the abstract data types. The sequential
specification of an abstract data type is the language that it recognizes.

We illustrate this part by focusing on four abstract data types: the integer set
(Figure 1.1), the sliding window register (Figure 1.2), the queue (Figure 1.3) and
memory (Figure 1.4).

1.2.1. Abstract data types

The model that we utilize is a form of transducer which is very similar to a Mealy
machine [MEA 55], except that in this case an infinite – but countable – number of
states is accepted. The values that may be taken by the data type are encoded in the
abstract state, taken from a set Z. It is possible to access the object by making use of
the symbols of an input alphabet A. Contrary to class methods, the input symbols of
the abstract data type do not have arguments. As a matter of fact, as a potentially
infinite set of operations is allowed, the call to the same method with different
arguments is encoded with different symbols. For example, the set (Figure 1.1) has as
many insertion input symbols I(v) as there are elements v to be inserted. These
symbols correspond to the same method I called with an argument in an
implementation. A method can have two types of effects. On the one hand, it may
cause a side effect, which changes the abstract state. The corresponding transition in
the transitions system is formalized by a transition function τ . On the other hand,
4 Distributed Systems

methods can have a return value taken from an output alphabet B, depending on the
state in which they are called, and on an output function δ. For example, the pop
method in a stack removes the element at the top of the stack (this is its side-effect)
and returns that element (this is its output). The formal definition of abstract data
types is given in definition 1.2.

D EFINITION 1.2.– An abstract data type (ADT) is a sextuplet T = (A, B, Z, ζ0 , τ, δ)


where:
– A is a countable set called input alphabet;
– B is a countable set called output alphabet;
– Z is a countable set of abstract states and ζ0 ∈ Z is the initial state;
– τ : Z × A → Z is the transition function;
– δ : Z × A → B is the output function.

We consider abstract data types up to isomorphism because the names of the states
are never directly used. In addition, we assume that functions τ and δ are computable
by a Turing machine to ensure that the difficulties in the implementation are only
related to the management of concurrency. The set of ADTs is denoted by T .

The transition function is complete, which expresses the fact that the object reacts
to all the external stresses imposed by the user. It is possible to model the fact that a
call is incongruous at a given time (for example, during an attempt to place a white
pawn when it is the black player’s turn in a game of Go) by a loop on certain states or
by an error state. In the ADT set, deleting an object that has never been inserted has no
effect. This is supported by the fact that τ (ζ, D(v)) = ζ if v ∈ ζ. The transition system
is also deterministic, which prevents the modeling of objects such as certain types of
heaps that have a method to return any of the objects inserted. It would be possible to
extend the model to probabilistic or deterministic ADTs, but we have decided not to
do so here, as to not add complexity which is not directly related to the topic under
study.

We will now see how the instant messaging services of the experiments in the
introduction can be modeled in the form of abstract data types. They include a write
operation for sending any message and a read operation that displays the result on
the screen. When we are just modeling the contents of the screen, a read only returns
the last messages, displayed from the oldest to the most recent. We propose to model
the instant messaging services by means of sliding window registers, formally defined
in Figure 1.2. The size k of the sliding window register represents the number of
messages that can be displayed on the screen. Sending a message, like writing to the
sliding window register, places the argument at the end of the message queue and the
read returns the k last written values.
Specification of Shared Objects 5

Figure 1.1. Sequential specification of a set

1.2.2. Sequential specifications

The succession of method calls of an object by a sequential program form a


sequence of operations admitted by the object. An abstract data type defines the
sequential specification of an object, i.e. the set of sequential histories admitted by
the object that it describes. The naive way to describe the language recognized by an
ADT is to consider the set of infinite paths that traverse its transitions system. This
set is too restrictive in the context of this work. In the sequential specification
(definition 1.5), we allow the knowledge of histories to be partial. Therefore, we
accept finite histories, which are the prefixes of infinite histories, as well as histories
6 Distributed Systems

in which some output values are unknown. The sequential specification is therefore a
language of finite and infinite words on an operation alphabet (definition 1.4)
comprising the input symbols sometimes associated with an output symbol.

D EFINITION 1.4.– Let T = (A, B, Z, ζ0 , τ, δ) an abstract data type.

An operation of T is an element of Σ = A ∪ (A × B). A pair


(α, β) ∈ A × B is denoted α/β.

We extend the transition function τ to the operations by applying τ to the input


symbol of the operations:


⎨ Z×Σ → Z
τT : (ζ, α) → τ (ζ, α) if α ∈ A

(ζ, α/β) → τ (ζ, α) if α/β ∈ A × B

We also define the function δT−1 that returns the set of states of T , in which a given
operation can be performed:


⎨ Σ → P(Z)
δT−1 : α → Z if α ∈ A

α/β → {ζ ∈ Z : δ(ζ, α) = β} if α/β ∈ A × B

C OMMENT 1.1.– A symbol of A can be referred to, depending on the context, by the
terms “operation”, “method” and “input alphabet symbol”. When there is no
ambiguity, we will favor the term “operation” (in particular to describe algorithms),
relatively less connoted to programming languages than the term “method” and more
explicit than the term “input alphabet symbol”.

D EFINITION 1.5.– A finite or infinite sequence σ = (σi )i∈D ∈ Σ∞ , where D is either


N or {0, ..., |σ| − 1}, is a sequential history of an ADT T if there is a sequence of the
same length (ζi+1 )i∈D ∈ Z∞ of states of T (ζ0 being already defined as the initial
state) such that for any i ∈ D,
– the eventual output symbol of σi is compatible with ζi : ζi ∈ δT−1 (σi );
– the execution of σi causes the state ζi to change into the state ζi+1 :
τT (ζi , σi ) = ζi+1 .

The sequential specification of T , denoted by L(T ), is the set of its sequential


histories.
Specification of Shared Objects 7

Figure 1.2. Sequential specification of the sliding window register

1.2.3. Updates and queries

It is often useful to classify operations according to their effects. The side effect of
an operation will be called its update part and the link between its state and its return
value will be called its query part. Certain operations which only have one query or
update part are referred to as pure. Definition 1.8 thus classifies operations into four
8 Distributed Systems

categories: update operations that modify the abstract state, query operations whose
return value depends on the abstract state, as well as pure update (resp. pure query)
operations that are not query (respectively update) operations.

D EFINITION 1.8.– Let an abstract data type T = (A, B, Z, ζ0 , τ, δ) and an input


symbol α ∈ A.
– α is a pure query if it has no side effects, i.e. if ∀ζ ∈ Z, τ (ζ, α) = ζ. The set of
pure queries of T is denoted by Q̂T .
– α is a pure update if the value it returns, called its dummy value, is independent
of the state, i.e. if ∃β ∈ B, ∀ζ ∈ Z, δ(ζ, α) = β. The set of pure updates of T is
denoted by ÛT . When there is no risk of ambiguity between α/β and α, we omit the
return symbol in pure updates in order to simplify the notation.
– α is a query if it is not a pure update, if α ∈ QT = A \ ÛT .
– α is an update if it is not a pure query, if α ∈ UT = A \ Q̂T .

For example, insertion and deletion operations of the set are pure updates and R
is a pure query. Some operations are also neither pure queries nor pure updates. This
is, for example, the case of the operation pop of the queue (Figure 1.3) which has
both an update portion because it removes the head of the queue and a query part
because it returns that element. Operations that are both pure queries and pure updates
are generally introspection operations that return information about the type itself,
such as the getClass method in Java. These operations are less interesting to study
because they do not raise any concurrency problems.

An Update-Query Abstract Data Type (UQ-ADT) T is a particular ADT for


which each operation is either a pure query or a pure update, i.e. ÛT ∪ Q̂T = A and
UT ∩ QT = ∅. The set is an example thereof. The set of UQ-ADT is denoted by
TU Q .

It is always possible to transform any ADT into a UQ-ADT by separating the query
part from the update part in operations that both occur at the same time. Revisiting the
example of the queue, the operation pop can be split into an operation hd that solely
returns the head of the queue without altering it (pure query) and an operation rh that
removes the head of the queue without returning its value (pure update). Definition 1.9
explains a generic transformation procedure. The operations α that correspond both to
a query and an update are split therein into a pure query αQ and a pure update αU .
Another random document with
no related content on Scribd:
material well-being, incalculable though this debt is. Beyond the fact
that we are an independent and united people, with half a continent
as our heritage, lies the fact that every American is richer by the
heritage of the noble deeds and noble words of Washington and of
Lincoln. Each of us who reads the Gettysburg speech or the second
inaugural address of the greatest American of the nineteenth
century, or who studies the long campaigns and lofty statesmanship
of that other American who was even greater, cannot but feel within
him that lift toward things higher and nobler which can never be
bestowed by the enjoyment of mere material prosperity.
It is not only the country which these men helped to make and
helped to save that is ours by inheritance; we inherit also all that is
best and highest in their characters and in their lives. We inherit from
Lincoln and from the might of Lincoln’s generation not merely the
freedom of those who once were slaves; for we inherit also the fact
of the freeing of them, we inherit the glory and the honor and the
wonder of the deed that was done, no less than the actual results of
the deed when done. The bells that rang at the passage of the
Emancipation Proclamation still ring in Whittier’s ode; and as men
think over the real nature of the triumph then scored for humankind
their hearts shall ever throb as they cannot over the greatest
industrial success or over any victory won at a less cost than ours.
The captains and the armies who, after long years of dreary
campaigning and bloody, stubborn fighting, brought to a close the
Civil War have likewise left us even more than a reunited realm. The
material effect of what they did is shown in the fact that the same
flag flies from the Great Lakes to the Rio Grande, and all the people
of the United States are richer because they are one people and not
many, because they belong to one great nation and not to a
contemptible knot of struggling nationalities. But besides this,
besides the material results of the Civil War, we are all, North and
South, incalculably richer for its memories. We are the richer for
each grim campaign, for each hard-fought battle. We are the richer
for valor displayed alike by those who fought so valiantly for the right
and by those who, no less valiantly, fought for what they deemed the
right. We have in us nobler capacities for what is great and good
because of the infinite woe and suffering, and because of the
splendid ultimate triumph.
In the same way that we are the better for the deeds of our mighty
men who have served the nation well, so we are the worse for the
deeds and the words of those who have striven to bring evil on the
land. Most fortunately we have been free from the peril of the most
dangerous of all examples. We have not had to fight the influence
exerted over the minds of eager and ambitious men by the career of
the military adventurer who heads some successful revolutionary or
separatist movement. No man works such incalculable woe to a free
country as he who teaches young men that one of the paths to glory,
renown, and temporal success lies along the line of armed
resistance to the Government, of its attempted overthrow.
Yet if we are free from the peril of this example, there are other
perils from which we are not free. All through our career we have had
to war against a tendency to regard, in the individual and the nation
alike, as most important, things that are of comparatively little
importance. We rightfully value success, but sometimes we
overvalue it, for we tend to forget that success may be obtained by
means which should make it abhorred and despised by every
honorable man. One section of the community deifies as “smartness”
the kind of trickery which enables a man without conscience to
succeed in the financial or political world. Another section of the
community deifies violent homicidal lawlessness. If ever our people
as a whole adopt these views, then we shall have proved that we are
unworthy of the heritage our forefathers left us; and our country will
go down in ruin.
The people that do harm in the end are not the wrong-doers whom
all execrate; they are the men who do not do quite as much wrong,
but who are applauded instead of being execrated. The career of
Benedict Arnold has done us no harm as a nation because of the
universal horror it inspired. The men who have done us harm are
those who have advocated disunion, but have done it so that they
have been enabled to keep their political position; who have
advocated repudiation of debts, or other financial dishonesty, but
have kept their standing in the community; who preach the doctrines
of anarchy, but refrain from action that will bring them within the pale
of the law; for these men lead thousands astray by the fact that they
go unpunished or even rewarded for their misdeeds.
It is unhappily true that we inherit the evil as well as the good done
by those who have gone before us, and in the one case as in the
other the influence extends far beyond the mere material effects.
The foes of order harm quite as much by example as by what they
actually accomplish. So it is with the equally dangerous criminals of
the wealthy classes. The conscienceless stock speculator who
acquires wealth by swindling his fellows, by debauching judges and
corrupting legislatures, and who ends his days with the reputation of
being among the richest men in America, exerts over the minds of
the rising generation an influence worse than that of the average
murderer or bandit, because his career is even more dazzling in its
success, and even more dangerous in its effects upon the
community. Any one who reads the essays of Charles Francis
Adams and Henry Adams, entitled “A Chapter of Erie,” and “The
Gold Conspiracy in New York,” will read about the doings of men
whose influence for evil upon the community is more potent than that
of any band of anarchists or train robbers.
There are other members of our mercantile community who, being
perfectly honest themselves, nevertheless do almost as much
damage as the dishonest. The professional labor agitator, with all his
reckless incendiarism of speech, can do no more harm than the
narrow, hard, selfish merchant or manufacturer who deliberately sets
himself to keep the laborers he employs in a condition of
dependence which will render them helpless to combine against him;
and every such merchant or manufacturer who rises to sufficient
eminence leaves the record of his name and deeds as a legacy of
evil to all who come after him.
But of course the worst foes of America are the foes to that orderly
liberty without which our Republic must speedily perish. The reckless
labor agitator who arouses the mob to riot and bloodshed is in the
last analysis the most dangerous of the workingman’s enemies. This
man is a real peril; and so is his sympathizer, the legislator, who to
catch votes denounces the judiciary and the military because they
put down mobs. We Americans have, on the whole, a right to be
optimists; but it is mere folly to blind ourselves to the fact that there
are some black clouds on the horizon of our future.
During the summer of 1894, every American capable of thinking
must at times have pondered very gravely over certain features of
the national character which were brought into unpleasant
prominence by the course of events. The demagogue, in all his
forms, is as characteristic an evil of a free society as the courtier is of
a despotism; and the attitude of many of our public men at the time
of the great strike in July, 1894, was such as to call down on their
heads the hearty condemnation of every American who wishes well
to his country. It would be difficult to overestimate the damage done
by the example and action of a man like Governor Altgeld of Illinois.
Whether he is honest or not in his beliefs is not of the slightest
consequence. He is as emphatically the foe of decent government
as Tweed himself, and is capable of doing far more damage than
Tweed. The Governor, who began his career by pardoning
anarchists, and whose most noteworthy feat since was his bitter and
undignified, but fortunately futile, campaign against the election of
the upright judge who sentenced the anarchists, is the foe of every
true American and is the foe particularly of every honest
workingman. With such a man it was to be expected that he should
in time of civic commotion act as the foe of the law-abiding and the
friend of the lawless classes, and endeavor, in company with the
lowest and most abandoned office-seeking politicians, to prevent
proper measures being taken to prevent riot and to punish the
rioters. Had it not been for the admirable action of the Federal
Government, Chicago would have seen a repetition of what occurred
during the Paris Commune, while Illinois would have been torn by a
fierce social war; and for all the horrible waste of life that this would
have entailed Governor Altgeld would have been primarily
responsible. It was a most fortunate thing that the action at
Washington was so quick and so emphatic. Senator Davis of
Minnesota set the key of patriotism at the time when men were still
puzzled and hesitated. The President and Attorney-General Olney
acted with equal wisdom and courage, and the danger was averted.
The completeness of the victory of the Federal authorities,
representing the cause of law and order, has been perhaps one
reason why it was so soon forgotten; and now not a few shortsighted
people need to be reminded that when we were on the brink of an
almost terrific explosion the governor of Illinois did his best to work to
this country a measure of harm as great as any ever planned by
Benedict Arnold, and that we were saved by the resolute action of
the Federal judiciary and of the regular army. Moreover, Governor
Altgeld, though pre-eminent, did not stand alone on his unenviable
prominence. Governor Waite of Colorado stood with him. Most of the
Populist governors of the Western States, and the Republican
governor of California and the Democratic governor of North Dakota,
shared the shame with him; and it makes no difference whether in
catering to riotous mobs they paid heed to their own timidity and
weakness, or to that spirit of blatant demagogism which, more than
any other, jeopardizes the existence of free institutions. On the other
hand, the action of the then Governor of Ohio, Mr. McKinley, entitled
him to the gratitude of all good citizens.
Every true American, every man who thinks, and who if the
occasion comes is ready to act, may do well to ponder upon the evil
wrought by the lawlessness of the disorderly classes when once they
are able to elect their own chiefs to power. If the Government
generally got into the hands of men such as Altgeld, the Republic
would go to pieces in a year; and it would be right that it should go to
pieces, for the election of such men shows that the people electing
them are unfit to be entrusted with self-government.
There are, however, plenty of wrong-doers besides those who
commit the overt act. Too much cannot be said against the men of
wealth who sacrifice everything to getting wealth. There is not in the
world a more ignoble character than the mere money-getting
American, insensible to every duty, regardless of every principle,
bent only on amassing a fortune, and putting his fortune only to the
basest uses—whether these uses be to speculate in stocks and
wreck railroads himself, or to allow his son to lead a life of foolish
and expensive idleness and gross debauchery, or to purchase some
scoundrel of high social position, foreign or native, for his daughter.
Such a man is only the more dangerous if he occasionally does
some deed like founding a college or endowing a church, which
makes those good people who are also foolish forget his real iniquity.
These men are equally careless of the workingmen, whom they
oppress, and of the state, whose existence they imperil. There are
not very many of them, but there is a very great number of men who
approach more or less closely to the type, and, just in so far as they
do so approach, they are curses to the country. The man who is
content to let politics go from bad to worse, jesting at the corruption
of politicians, the man who is content to see the maladministration of
justice without an immediate and resolute effort to reform it, is
shirking his duty and is preparing the way for infinite woe in the
future. Hard, brutal indifference to the right, and an equally brutal
shortsightedness as to the inevitable results of corruption and
injustice, are baleful beyond measure; and yet they are characteristic
of a great many Americans who think themselves perfectly
respectable, and who are considered thriving, prosperous men by
their easy-going fellow-citizens.
Another class, merging into this, and only less dangerous, is that
of the men whose ideals are purely material. These are the men who
are willing to go for good government when they think it will pay, but
who measure everything by the shop-till, the people who are unable
to appreciate any quality that is not a mercantile commodity, who do
not understand that a poet may do far more for a country than the
owner of a nail factory, who do not realize that no amount of
commercial prosperity can supply the lack of the heroic virtues, or
can in itself solve the terrible social problems which all the civilized
world is now facing. The mere materialist is, above all things, short-
sighted. In a recent article Mr. Edward Atkinson casually mentioned
that the regular army could now render the country no “effective or
useful service.” Two months before this sapient remark was printed
the regular army had saved Chicago from the fate of Paris in 1870
and had prevented a terrible social war in the West. At the end of
this article Mr. Atkinson indulged in a curious rhapsody against the
navy, denouncing its existence and being especially wrought up, not
because war-vessels take life, but because they “destroy
commerce.” To men of a certain kind, trade and property are far
more sacred than life or honor, of far more consequence than the
great thoughts and lofty emotions, which alone make a nation
mighty. They believe, with a faith almost touching in its utter
feebleness, that “the Angel of Peace, draped in a garment of
untaxed calico,” has given her final message to men when she has
implored them to devote all their energies to producing
oleomargarine at a quarter of a cent less a firkin, or to importing
woollens for a fraction less than they can be made at home. These
solemn prattlers strive after an ideal in which they shall happily unite
the imagination of a green-grocer with the heart of a Bengalee
baboo. They are utterly incapable of feeling one thrill of generous
emotion, or the slightest throb of that pulse which gives to the world
statesmen, patriots, warriors, and poets, and which makes a nation
other than a cumberer of the world’s surface. In the concluding page
of his article Mr. Atkinson, complacently advancing his panacea, his
quack cure-all, says that “all evil powers of the world will go down
before” a policy of “reciprocity of trade without obstruction”! Fatuity
can go no farther.
No Populist who wishes a currency based on corn and cotton
stands in more urgent need of applied common sense than does the
man who believes that the adoption of any policy; no matter what, in
reference to our foreign commerce, will cut that tangled knot of social
well-being and misery at which the fingers of the London free-trader
clutch as helplessly as those of the Berlin protectionist. Such a man
represents individually an almost imponderable element in the work
and thought of the community; but in the aggregate he stands for a
real danger, because he stands for a feeling evident of late years
among many respectable people. The people who pride themselves
upon having a purely commercial ideal are apparently unaware that
such an ideal is as essentially mean and sordid as any in the world,
and that no bandit community of the Middle Ages can have led a
more unlovely life than would be the life of men to whom trade and
manufactures were everything, and to whom such words as national
honor and glory, as courage and daring, and loyalty and
unselfishness, had become meaningless. The merely material, the
merely commercial ideal, the ideal of the men “whose fatherland is
the till,” is in its very essence debasing and lowering. It is as true
now as ever it was that no man and no nation shall live by bread
alone. Thrift and industry are indispensable virtues; but they are not
all-sufficient. We must base our appeals for civic and national
betterment on nobler grounds than those of mere business
expediency.
We have examples enough and to spare that tend to evil;
nevertheless, for our good fortune, the men who have most
impressed themselves upon the thought of the nation have left
behind them careers the influence of which must tell for good. The
unscrupulous speculator who rises to enormous wealth by swindling
his neighbor; the capitalist who oppresses the workingman; the
agitator who wrongs the workingman yet more deeply by trying to
teach him to rely not upon himself, but partly upon the charity of
individuals or of the state and partly upon mob violence; the man in
public life who is a demagogue or corrupt, and the newspaper writer
who fails to attack him because of his corruption, or who
slanderously assails him when he is honest; the political leader who,
cursed by some obliquity of moral or of mental vision, seeks to
produce sectional or social strife—all these, though important in their
day, have hitherto failed to leave any lasting impress upon the life of
the nation. The men who have profoundly influenced the growth of
our national character have been in most cases precisely those men
whose influence was for the best and was strongly felt as
antagonistic to the worst tendency of the age. The great writers, who
have written in prose or verse, have done much for us. The great
orators whose burning words on behalf of liberty, of union, of honest
government, have rung through our legislative halls, have done even
more. Most of all has been done by the men who have spoken to us
through deeds and not words, or whose words have gathered their
especial charm and significance because they came from men who
did speak in deeds. A nation’s greatness lies in its possibility of
achievement in the present, and nothing helps it more than the
consciousness of achievement in the past.
FOOTNOTES:
[2] The Forum, February, 1895.
II
TRUE AMERICANISM[3]

Patriotism was once defined as “the last refuge of a scoundrel”;


and somebody has recently remarked that when Dr. Johnson gave
this definition he was ignorant of the infinite possibilities contained in
the word “reform.” Of course both gibes were quite justifiable, in so
far as they were aimed at people who use noble names to cloak
base purposes. Equally of course the man shows little wisdom and a
low sense of duty who fails to see that love of country is one of the
elemental virtues, even though scoundrels play upon it for their own
selfish ends; and, inasmuch as abuses continually grow up in civic
life as in all other kinds of life, the statesman is indeed a weakling
who hesitates to reform these abuses because the word “reform” is
often on the lips of men who are silly or dishonest.
What is true of patriotism and reform is true also of Americanism.
There are plenty of scoundrels always ready to try to belittle reform
movements or to bolster up existing iniquities in the name of
Americanism; but this does not alter the fact that the man who can
do most in this country is and must be the man whose Americanism
is most sincere and intense. Outrageous though it is to use a noble
idea as the cloak for evil, it is still worse to assail the noble idea itself
because it can thus be used. The men who do iniquity in the name of
patriotism, of reform, of Americanism, are merely one small division
of the class that has always existed and will always exist,—the class
of hypocrites and demagogues, the class that is always prompt to
steal the watchwords of righteousness and use them in the interests
of evil-doing.
The stoutest and truest Americans are the very men who have the
least sympathy with the people who invoke the spirit of Americanism
to aid what is vicious in our government or to throw obstacles in the
way of those who strive to reform it. It is contemptible to oppose a
movement for good because that movement has already succeeded
somewhere else, or to champion an existing abuse because our
people have always been wedded to it. To appeal to national
prejudice against a given reform movement is in every way unworthy
and silly. It is as childish to denounce free trade because England
has adopted it as to advocate it for the same reason. It is eminently
proper, in dealing with the tariff, to consider the effect of tariff
legislation in time past upon other nations as well as the effect upon
our own; but in drawing conclusions it is in the last degree foolish to
try to excite prejudice against one system because it is in vogue in
some given country, or to try to excite prejudice in its favor because
the economists of that country have found that it was suited to their
own peculiar needs. In attempting to solve our difficult problem of
municipal government it is mere folly to refuse to profit by whatever
is good in the examples of Manchester and Berlin because these
cities are foreign, exactly as it is mere folly blindly to copy their
examples without reference to our own totally different conditions. As
for the absurdity of declaiming against civil-service reform, for
instance, as “Chinese,” because written examinations have been
used in China, it would be quite as wise to declaim against
gunpowder because it was first utilized by the same people. In short,
the man who, whether from mere dull fatuity or from an active
interest in misgovernment, tries to appeal to American prejudice
against things foreign, so as to induce Americans to oppose any
measure for good, should be looked on by his fellow-countrymen
with the heartiest contempt. So much for the men who appeal to the
spirit of Americanism to sustain us in wrong-doing. But we must
never let our contempt for these men blind us to the nobility of the
idea which they strive to degrade.
We Americans have many grave problems to solve, many
threatening evils to fight, and many deeds to do, if, as we hope and
believe, we have the wisdom, the strength, the courage, and the
virtue to do them. But we must face facts as they are. We must
neither surrender ourselves to a foolish optimism, nor succumb to a
timid and ignoble pessimism. Our nation is that one among all the
nations of the earth which holds in its hands the fate of the coming
years. We enjoy exceptional advantages, and are menaced by
exceptional dangers; and all signs indicate that we shall either fail
greatly or succeed greatly. I firmly believe that we shall succeed; but
we must not foolishly blink the dangers by which we are threatened,
for that is the way to fail. On the contrary, we must soberly set to
work to find out all we can about the existence and extent of every
evil, must acknowledge it to be such, and must then attack it with
unyielding resolution. There are many such evils, and each must be
fought after a separate fashion; yet there is one quality which we
must bring to the solution of every problem,—that is, an intense and
fervid Americanism. We shall never be successful over the dangers
that confront us; we shall never achieve true greatness, nor reach
the lofty ideal which the founders and preservers of our mighty
Federal Republic have set before us, unless we are Americans in
heart and soul, in spirit and purpose, keenly alive to the responsibility
implied in the very name of American, and proud beyond measure of
the glorious privilege of bearing it.
There are two or three sides to the question of Americanism, and
two or three senses in which the word “Americanism” can be used to
express the antithesis of what is unwholesome and undesirable. In
the first place we wish to be broadly American and national, as
opposed to being local or sectional. We do not wish, in politics, in
literature, or in art, to develop that unwholesome parochial spirit, that
over-exaltation of the little community at the expense of the great
nation, which produces what has been described as the patriotism of
the village, the patriotism of the belfry. Politically, the indulgence of
this spirit was the chief cause of the calamities which befell the
ancient republics of Greece, the mediæval republics of Italy, and the
petty States of Germany as it was in the last century. It is this spirit of
provincial patriotism, this inability to take a view of broad adhesion to
the whole nation that has been the chief among the causes that have
produced such anarchy in the South American States, and which
have resulted in presenting to us, not one great Spanish-American
federal nation stretching from the Rio Grande to Cape Horn, but a
squabbling multitude of revolution-ridden States, not one of which
stands even in the second rank as a power. However, politically this
question of American nationality has been settled once for all. We
are no longer in danger of repeating in our history the shameful and
contemptible disasters that have befallen the Spanish possessions
on this continent since they threw off the yoke of Spain. Indeed there
is, all through our life, very much less of this parochial spirit than
there was formerly. Still there is an occasional outcropping here and
there; and it is just as well that we should keep steadily in mind the
futility of talking of a Northern literature or a Southern literature, an
Eastern or a Western school of art or science. Joel Chandler Harris
is emphatically a national writer; so is Mark Twain. They do not write
merely for Georgia or Missouri or California any more than for Illinois
or Connecticut; they write as Americans and for all people who can
read English. St. Gaudens lives in New York; but his work is just as
distinctive of Boston or Chicago. It is of very great consequence that
we should have a full and ripe literary development in the United
States, but it is not of the least consequence whether New York, or
Boston, or Chicago, or San Francisco becomes the literary or artistic
centre of the United States.
There is a second side to this question of a broad Americanism,
however. The patriotism of the village or the belfrey is bad, but the
lack of all patriotism is even worse. There are philosophers who
assure us, that in the future, patriotism will be regarded not as a
virtue at all, but merely as a mental stage in the journey toward a
state of feeling when our patriotism will include the whole human
race and all the world. This may be so; but the age of which these
philosophers speak is still several æons distant. In fact, philosophers
of this type are so very advanced that they are of no practical service
to the present generation. It may be, that in ages so remote that we
cannot now understand any of the feelings of those who will dwell in
them, patriotism will no longer be regarded as a virtue, exactly as it
may be that in those remote ages people will look down upon and
disregard monogamic marriage; but as things now are and have
been for two or three thousand years past, and are likely to be for
two or three thousand years to come, the words “home” and
“country” mean a great deal. Nor do they show any tendency to lose
their significance. At present, treason, like adultery, ranks as one of
the worst of all possible crimes.
One may fall very far short of treason and yet be an undesirable
citizen in the community. The man who becomes Europeanized, who
loses his power of doing good work on this side of the water, and
who loses his love for his native land, is not a traitor; but he is a silly
and undesirable citizen. He is as emphatically a noxious element in
our body politic as is the man who comes here from abroad and
remains a foreigner. Nothing will more quickly or more surely
disqualify a man from doing good work in the world than the
acquirement of that flaccid habit of mind which its possessors style
cosmopolitanism.
It is not only necessary to Americanize the immigrants of foreign
birth who settle among us, but it is even more necessary for those
among us who are by birth and descent already Americans not to
throw away our birthright, and, with incredible and contemptible folly,
wander back to bow down before the alien gods whom our
forefathers forsook. It is hard to believe that there is any necessity to
warn Americans that, when they seek to model themselves on the
lines of other civilizations, they make themselves the butts of all
right-thinking men; and yet the necessity certainly exists to give this
warning to many of our citizens who pride themselves on their
standing in the world of art and letters, or, perchance, on what they
would style their social leadership in the community. It is always
better to be an original than an imitation, even when the imitation is
of something better than the original; but what shall we say of the
fool who is content to be an imitation of something worse? Even if
the weaklings who seek to be other than Americans were right in
deeming other nations to be better than their own, the fact yet
remains that to be a first-class American is fifty-fold better than to be
a second-class imitation of a Frenchman or Englishman. As a matter
of fact, however, those of our countrymen who do believe in
American inferiority are always individuals who, however cultivated,
have some organic weakness in their moral or mental make-up; and
the great mass of our people, who are robustly patriotic, and who
have sound, healthy minds, are justified in regarding these feeble
renegades with a half-impatient and half-amused scorn.
We believe in waging relentless war on rank-growing evils of all
kinds, and it makes no difference to us if they happen to be of purely
native growth. We grasp at any good, no matter whence it comes.
We do not accept the evil attendant upon another system of
government as an adequate excuse for that attendant upon our own;
the fact that the courtier is a scamp does not render the demagogue
any the less a scoundrel. But it remains true that, in spite of all our
faults and shortcomings, no other land offers such glorious
possibilities to the man able to take advantage of them, as does
ours; it remains true that no one of our people can do any work really
worth doing unless he does it primarily as an American. It is because
certain classes of our people still retain their spirit of colonial
dependence on, and exaggerated deference to, European opinion,
that they fail to accomplish what they ought to. It is precisely along
the lines where we have worked most independently that we have
accomplished the greatest results; and it is in those professions
where there has been no servility to, but merely a wise profiting by,
foreign experience, that we have produced our greatest men. Our
soldiers and statesmen and orators; our explorers, our wilderness-
winners, and commonwealth-builders; the men who have made our
laws and seen that they were executed; and the other men whose
energy and ingenuity have created our marvellous material
prosperity,—all these have been men who have drawn wisdom from
the experience of every age and nation, but who have nevertheless
thought, and worked, and conquered, and lived, and died, purely as
Americans; and on the whole they have done better work than has
been done in any other country during the short period of our
national life.
On the other hand, it is in those professions where our people
have striven hardest to mould themselves in conventional European
forms that they have succeeded least; and this holds true to the
present day, the failure being of course most conspicuous where the
man takes up his abode in Europe; where he becomes a second-
rate European, because he is over-civilized, over-sensitive, over-
refined, and has lost the hardihood and manly courage by which
alone he can conquer in the keen struggle of our national life. Be it
remembered, too, that this same being does not really become a
European; he only ceases being an American, and becomes nothing.
He throws away a great prize for the sake of a lesser one, and does
not even get the lesser one. The painter who goes to Paris, not
merely to get two or three years’ thorough training in his art, but with
the deliberate purpose of taking up his abode there, and with the
intention of following in the ruts worn deep by ten thousand earlier
travellers, instead of striking off to rise or fall on a new line, thereby
forfeits all chance of doing the best work. He must content himself
with aiming at that kind of mediocrity which consists in doing fairly
well what has already been done better; and he usually never even
sees the grandeur and picturesqueness lying open before the eyes
of every man who can read the book of America’s past and the book
of America’s present. Thus it is with the undersized man of letters,
who flees his country because he, with his delicate, effeminate
sensitiveness, finds the conditions of life on this side of the water
crude and raw; in other words, because he finds that he cannot play
a man’s part among men, and so goes where he will be sheltered
from the winds that harden stouter souls. This emigré may write
graceful and pretty verses, essays, novels; but he will never do work
to compare with that of his brother, who is strong enough to stand on
his own feet, and do his work as an American. Thus it is with the
scientist who spends his youth in a German university, and can
thenceforth work only in the fields already fifty times furrowed by the
German ploughs. Thus it is with that most foolish of parents who
sends his children to be educated abroad, not knowing—what every
clear-sighted man from Washington and Jay down has known—that
the American who is to make his way in America should be brought
up among his fellow Americans. It is among the people who like to
consider themselves, and, indeed, to a large extent are, the leaders
of the so-called social world, especially in some of the northeastern
cities, that this colonial habit of thought, this thoroughly provincial
spirit of admiration for things foreign, and inability to stand on one’s
own feet, becomes most evident and most despicable. We believe in
every kind of honest and lawful pleasure, so long as the getting it is
not made man’s chief business; and we believe heartily in the good
that can be done by men of leisure who work hard in their leisure,
whether at politics or philanthropy, literature or art. But a leisure
class whose leisure simply means idleness is a curse to the
community, and in so far as its members distinguish themselves
chiefly by aping the worst—not the best—traits of similar people
across the water, they become both comic and noxious elements of
the body politic.
The third sense in which the word “Americanism” may be
employed is with reference to the Americanizing of the newcomers to
our shores. We must Americanize them in every way, in speech, in
political ideas and principles, and in their way of looking at the
relations between Church and State. We welcome the German or
the Irishman who becomes an American. We have no use for the
German or Irishman who remains such. We do not wish German-
Americans and Irish-Americans who figure as such in our social and
political life; we want only Americans, and, provided they are such,
we do not care whether they are of native or of Irish or of German
ancestry. We have no room in any healthy American community for a
German-American vote or an Irish-American vote, and it is
contemptible demagogy to put planks into any party platform with the
purpose of catching such a vote. We have no room for any people
who do not act and vote simply as Americans, and as nothing else.
Moreover, we have as little use for people who carry religious
prejudices into our politics as for those who carry prejudices of caste
or nationality. We stand unalterably in favor of the public-school
system in its entirety. We believe that English, and no other
language, is that in which all the school exercises should be
conducted. We are against any division of the school fund, and
against any appropriation of public money for sectarian purposes.
We are against any recognition whatever by the State in any shape
or form of State-aided parochial schools. But we are equally
opposed to any discrimination against or for a man because of his
creed. We demand that all citizens, Protestant and Catholic, Jew and
Gentile, shall have fair treatment in every way; that all alike shall
have their rights guaranteed them. The very reasons that make us
unqualified in our opposition to State-aided sectarian schools make
us equally bent that, in the management of our public schools, the
adherents of each creed shall be given exact and equal justice,
wholly without regard to their religious affiliations; that trustees,
superintendents, teachers, scholars, all alike, shall be treated without
any reference whatsoever to the creed they profess. We maintain
that it is an outrage, in voting for a man for any position, whether
State or national, to take into account his religious faith, provided
only he is a good American. When a secret society does what in
some places the American Protective Association seems to have
done, and tries to proscribe Catholics both politically and socially, the
members of such society show that they themselves are as utterly
un-American, as alien to our school of political thought, as the worst
immigrants who land on our shores. Their conduct is equally base
and contemptible; they are the worst foes of our public-school
system, because they strengthen the hands of its ultramontane
enemies; they should receive the hearty condemnation of all
Americans who are truly patriotic.
The mighty tide of immigration to our shores has brought in its
train much of good and much of evil; and whether the good or the
evil shall predominate depends mainly on whether these newcomers
do or do not throw themselves heartily into our national life, cease to
be European, and become Americans like the rest of us. More than a
third of the people of the Northern States are of foreign birth or
parentage. An immense number of them have become completely
Americanized, and these stand on exactly the same plane as the
descendants of any Puritan, Cavalier, or Knickerbocker among us,
and do their full and honorable share of the nation’s work. But where
immigrants, or the sons of immigrants, do not heartily and in good
faith throw in their lot with us, but cling to the speech, the customs,
the ways of life, and the habits of thought of the Old World which
they have left, they thereby harm both themselves and us. If they
remain alien elements, unassimilated, and with interests separate
from ours, they are mere obstructions to the current of our national
life, and, moreover, can get no good from it themselves. In fact,
though we ourselves also suffer from their perversity, it is they who
really suffer most. It is an immense benefit to the European
immigrant to change him into an American citizen. To bear the name
of American is to bear the most honorable of titles; and whoever
does not so believe has no business to bear the name at all, and, if
he comes from Europe, the sooner he goes back there the better.
Besides, the man who does not become Americanized nevertheless
fails to remain a European, and becomes nothing at all. The
immigrant cannot possibly remain what he was, or continue to be a
member of the Old-World society. If he tries to retain his old
language, in a few generations it becomes a barbarous jargon; if he
tries to retain his old customs and ways of life, in a few generations
he becomes an uncouth boor. He has cut himself off from the Old-
World, and cannot retain his connection with it; and if he wishes ever
to amount to anything he must throw himself heart and soul, and
without reservation, into the new life to which he has come. It is
urgently necessary to check and regulate our immigration, by much
more drastic laws than now exist; and this should be done both to
keep out laborers who tend to depress the labor market, and to keep
out races which do not assimilate readily with our own, and unworthy
individuals of all races—not only criminals, idiots, and paupers, but
anarchists of the Most and O’Donovan Rossa type.
From his own standpoint, it is beyond all question the wise thing
for the immigrant to become thoroughly Americanized. Moreover,
from our standpoint, we have a right to demand it. We freely extend
the hand of welcome and of good-fellowship to every man, no matter
what his creed or birthplace, who comes here honestly intent on
becoming a good United States citizen like the rest of us; but we
have a right, and it is our duty, to demand that he shall indeed
become so, and shall not confuse the issues with which we are
struggling by introducing among us Old-World quarrels and
prejudices. There are certain ideas which he must give up. For
instance, he must learn that American life is incompatible with the
existence of any form of anarchy, or of any secret society having
murder for its aim, whether at home or abroad; and he must learn
that we exact full religious toleration and the complete separation of
Church and State. Moreover, he must not bring in his Old-World
religious race and national antipathies, but must merge them into
love for our common country, and must take pride in the things which
we can all take pride in. He must revere only our flag; not only must
it come first, but no other flag should even come second. He must
learn to celebrate Washington’s birthday rather than that of the
Queen or Kaiser, and the Fourth of July instead of St. Patrick’s Day.
Our political and social questions must be settled on their own
merits, and not complicated by quarrels between England and
Ireland, or France and Germany, with which we have nothing to do: it
is an outrage to fight an American political campaign with reference
to questions of European politics. Above all, the immigrant must
learn to talk and think and be United States.
The immigrant of to-day can learn much from the experience of
the immigrants of the past, who came to America prior to the
Revolutionary War. We were then already, what we are now, a
people of mixed blood. Many of our most illustrious Revolutionary
names were borne by men of Huguenot blood—Jay, Sevier, Marion,
Laurens. But the Huguenots were, on the whole, the best immigrants
we have ever received; sooner than any other, and more completely,
they became American in speech, conviction, and thought. The
Hollanders took longer than the Huguenots to become completely
assimilated; nevertheless they in the end became so, immensely to
their own advantage. One of the leading Revolutionary generals,
Schuyler, and one of the Presidents of the United States, Van Buren,
were of Dutch blood; but they rose to their positions, the highest in
the land, because they had become Americans and had ceased
being Hollanders. If they had remained members of an alien body,
cut off by their speech and customs and belief from the rest of the
American community, Schuyler would have lived his life as a boorish,
provincial squire, and Van Buren would have ended his days a small
tavern-keeper. So it is with the Germans of Pennsylvania. Those of
them who became Americanized have furnished to our history a
multitude of honorable names, from the days of the Mühlenbergs
onward; but those who did not become Americanized form to the
present day an unimportant body, of no significance in American
existence. So it is with the Irish, who gave to Revolutionary annals
such names as Carroll and Sullivan, and to the Civil War men like

You might also like