MySQL Error Lexicon #1

MySQL is justly famous for providing incomprehensible error messages.  The typical response to receiving one of these messages is to google for it, because someone else has almost certainly run into the same problem before, and the answer will be posted on a forum.

Perhaps because NDB is somewhat more exotic than MySQL itself, I have been privileged to encounter some messages that the Internets could not completely decode for me.  As a public service, I intend to annotate the unusual error messages I receive.

The first entry in this MySQL error lexicon is deceptively complicated.  It is actually a well known error message with a common meaning.  But like all the best words, it has another more subtle meaning.  I encounted it when one of our NDB API nodes died, and after rebooting, was unable to rejoin the cluster and provided only this message, which is contradictory on its face:

[MgmSrvr] Allocate nodeid (0) failed. Connection from ip 192.168.2.24. Returned error string "Connection done from wrong host ip 192.168.2.24."
I have found that message can mean any of the following:
  1. The obvious meaning: an NDB node has been configured to connect using the wrong IP address.  Perhaps the node id is specified in the connect string and it doesn't match the IP address of the node.
  2. A node is trying to connect but it hasn't been configured at all.  This is also very common, but does require a slightly more liberal interpretation of the error message.
  3. NDB allocates resources for each node that is configured, and as long as it believes that a node is connected, it will not let another process connect as the same node (be that by specifying the node id or auto-detecting the node id using the IP address). It may be that if the node has died in a particular way, ndb_mgmd still thinks that it is connected.  Issuing "PURGE STALE SESSIONS" from ndb_mgm may cause ndb_mgmd to recognize that the node is no longer connected.  Reports indicate that improvements to NDB may have rendered this problem obsolete.
  4. Just as ndb_mgmd allocates resources for each node, so do the data nodes.  And even if ndb_mgmd is aware that the problem node is not connected, the data nodes may mistakenly believe that it is, especially if it has died in an inopportune manner.  If the configuration is correct, and issuing "PURGE STALE SESSIONS" and restarting ndb_mgmd do not solve the problem, there may be a stale connection on a data node.  The command "lsof" will show whether ndbd has an open connection to the host that can not join the cluster.  If it does, a rolling restart of the data nodes may release the resources that are preventing the node from joining.

 

0 comments
Tags: db code

Read a Book by Remote Control

Array of LED modulesThe center-mounted ceiling fixture found in most homes is a lighting fixture whose best use is perhaps to provide enough light to install other lights. You are virtually guaranteed to cast a shadow on whatever task you undertake, or have the light source in your field of vision, or in some cases, both.

That's the case in my small apartment where the single futon that I use for reading and watching television sits against the wall, facing in. During the day, the window behind it lets plenty of sunlight in, but at night, the only light source is that ubiquitous ceiling fixture which, by virtue of being behind the book I'm reading (rather than behind me), doesn't do much to differentiate the type from the paper.

Of course the solution is to put a lamp beside the futon. But this isn't that kind of apartment. A lamp would take up precious floor space, and I'm using the floor for other things like standing and walking. I do have wall space though.

In fact, the ideal lamp for my situation would not take up any space, so that one isn't even aware of it if when off. It should be energy efficient, but not an ugly, toxic fluorescent lamp. A string of LEDs perched on the window frame would be just about right.

There are two lighting goals for this project. The first is to provide back fill light for reading a book. Most of the light in the room would still come from the ceiling fixture, but the LEDS will bounce extra light on the ceiling behind the reader and illuminate the page. The second goal is to have house lights for watching TV and movies. Lights that can be controlled by remote, so that after watching a movie in the dark, I don't have to stumble across the room to turn on the lights. The LEDs alone achieve the first goal. The second needs some computer automation.

A single LED module

The easiest way to control the LEDs and provide a nice dimming function to ease transitions in and out of black is to do pulse width modulation (PWM) which is electronic-speak for turning something on and off real fast. You could do this with just a parallel port on a computer, but it makes more sense to have a programmable controller like the one on an Arduino handle a task like that.

To construct the system, I bought 20 white LED modules from SparkFun, and strung them together in two channels of 10 modules each. The mounting brackets they provide (I broke off the screw attachment and just used the double sided tape) have enough room to thread the jumper cable for the second channel through the brackets for the first. With this method, alternating modules are on channels in an odd/even configuration. This is helpful in the low end of the dimming range where the ability to have the different channels at separate levels gives the appearance of smoother dimming.Graph of output functions

The Arduino is very simple to use. It has a Java based IDE so that you can instantly upload your programs to the controller and test them out. I wrote a program that receives input over the USB connection and sets PWM values appropriate for the desired light level. Setting the values linearly didn't produce a fade that felt linear, so I applied a simple exponential function to adjust the output to appear more linear. I used different functions for each channel so that in the lower part of the fade, the channels have values with different luminosity to smooth the lower end, but as they increase in value, they approach 1 and the output values are not much different in luminosity.

  • int(255*pow(x/255.0, 2.0))
  • int(255*pow(x/255.0, 1.6))

The next component is the software that controls the system. It listens for IR events from an IguanaWorks USB IR tranceiver via LIRC and fades the lights appropriately. It responds to direct on/off commands, but it also watches for commands sent to other systems to infer what is going on in the room. For instance, if it sees the TV turn on, it fades the lights up, then slowly to half. After seeing further IR activity, it fades the lights out on the assumption that everyone has found their seat. When the TV turns off, the lights come back up.

I could hook up a physical button or switch to the Arduino to control the lights as well, but since my remote is programmable, why add more clutter? I have a Harmony 880 universal remote, which is activity based. To use it, one begins by pressing a button for an activity such as "Watch a DVD" or "Watch TV". I added a new activity, which may be unusual for a remote control: "Read a book".

 Remote control

0 comments

Unicorn Chaser


The Unicorn Chaser airliner

We were happy passengers on the fabulous Unicorn Chaser.  The entertainment system, which runs under Linux, worked fairly well.  It had the usual assortment of free games that come with any GNU/Linux system, Creative Commons licensed videos, and unsurprisingly, some fun problems involving video overlay colors.  But really, should anything on an airplane be "beta"?

 

 

0 comments

The world learns a great deal about San Francisco

On Monday, United States Olympic Committee Chairman Peter Ueberroth said:

"The world will learn a great deal about San Francisco during the next two days ..." (source)

A group of police officers stands on an empty street
And the world has.  We've learned that San Francisco values the freedom of expression of its residents so little that it will deceive them in order to placate a foreign power.

The Olympics may not be about politics, but at this point it's disingenuous to claim that the torch isn't.

Thousands lined up on Wednesday along the published route of the Olympic torch to celebrate the unifying spirit of the Olympic games and China's extraordinary presence on the world stage, or to protest the policies of a repressive regime and their own government's unwillingness to take a strong stand for freedom.  But they never saw the torch -- the icon of Olympic politics that drew them out.

Instead, Mayor Gavin Newsom and San Francisco's police changed the route of the torch without notice as the relay started.  The torch was escorted through streets filled mostly with the phalanx of police guarding it, whisked around from site to site by bus, and returned quickly to the airport for a perfunctory closing "ceremony".

San Francisco has shown that it values image more than truth.  In retrospect, Beijing could not have chosen a better city for the torch's only North American stop.

Confusion strikes US torch relay

Olympic torch dodges S.F. protesters

Torch leaves San Francisco after surprise route designed to thwart protesters

Torch entries on SFist

 

photo by Scott Beale / Laughing Squid

0 comments