Monday, 27 November 2017

The Monica Geller excuse – ‘It’s hard for some people!’

(or “The one with Monica from Friends”)

Ross: Monica couldn't tell time till she was 13!
Monica: It's hard for some people!

(Friends, Season 7, “The One with Rachel’s assistant”)

I was having a conversation with a colleague about transport level security (TLS)

“Should we use Server-only TLS or Mutual (Client and Server) TLS?”

“Mutual’s really hard – let’s do Server-only for now”

“Or we could work out how to do it the right way . .”

“Yep, right: We need to do it properly – especially with security!”

How many sub-optimal architectures, designs and implementations do we have because ‘Something was hard to do’?

This is the “Monical Geller Excuse” – not doing something because ‘It’s hard for some people”.

Don’t confuse being easy to use for the end user, which is a laudable aim, with easy-to-architect/implement/design/develop.

“Who is going to know?” isn’t a reason (See front page of the news web sites when it crashes or gets compromised). You’re building up technical debt either for yourself or those who will come after you.

See also “What are the chances of that ever happening?” (Clue: FMEA is your friend) and “What could possibly go wrong?” (See previous).

A lot of sub-optimal, or ‘bodge’ solutions are used because there is a deadline to hit. IF this really is non-movable then at least log the technical debt and fix it properly.

John F Kennedy said ‘We choose to go to the moon in this decade and do the other things – not because they are easy, but because they are hard’.

He set a deadline ‘in this decade’. What most people do isn’t rocket science.


If your excuse is ‘It’s hard for some people’ then maybe you need to get better people . . .

Booking the last 2 seats at the theatre - an alternative way of explaining ACID transactions . . .

How to book two seats when there’s only a row of three in a cinema or theatre.

(Or ‘An alternative and obscure way of explaining ACID Transaction Processing’) 


"There are ways around that!" - David Lightman, Wargames.

You go to make a theatre booking. It’s busy and seats are ‘Selling fast! Book now!’

There are 3 left for your favourite comedian/band/orchestra/throat singers – and they are together! You and your favourite person can go to see the show and sit together. Great!

The following is an anthropomorphised version of the ‘conversation’ you and your browser will be having with the theatre website: 

“L21 and L22 please”

“I’m sorry, you can’t do that – that would leave L23 free which is a single seat and they are difficult to sell.”

“That’s your problem isn’t it? There are 3 left. I want two of them. Is it harder to sell one seat or three?”

“We have a ‘no single seats left’ policy. Do you not have another friend who would like to join you? It’s only £ker-ching for another ticket  . .”

Yes, you do have another friend – and it’s called another browser, or another computer.

How to solve the ‘no single seats left problem’ 

In browser (or computer) 1:

  • Log onto the theatre website and select the 2 seats you want in the block of 3
  • Wait just at the point before it gives you the ‘no single seats’ message.

(No one will want to book three, so you’re in no rush unless anyone else knows this trick)

Now, open up a new different browser/computer - this is browser/computer 2:

This is not a separate window or tab, as you may share the same cookies/session and it won’t work. e.g. if you started in Firefox, open Chrome or Safari for this 2nd part.

(Do NOT log in to the theatre website with your account or userid/password for this part – you must buy tickets as a ‘visitor’ or ‘unregistered user’)
  • In the 2nd browser (or computer) , select the 1 ‘other’ seat in your row of three. 
  • Important: Do not pay for the seat. Do not log in. Do not enter your credit card.
  • Get as far as the ‘Your seat has been held for 15 minutes’ (or whatever) screen.

**REPEAT: DO NOT BUY ANYTHING AT THIS POINT IN BROWSER 2**

Go back to browser/computer 1:

  • Click ‘select/buy my seats’ on your original selection – and you’re in!
  • You are able to select the seats now, even though you couldn't before.You might need to refresh and re-select them on some sites, but it should work.
  • You can now pay at your leisure, book meals, donate to the restoration fund, sign up to mailing lists and all the other fun things you can do on theatre websites.

 Go back to browser/computer 2:

  • Leave the seat selection/reservation on browser/computer 2 to expire.
  • (Just close the 2nd browser, or cllck ‘release tickets’ if there is such a button on the screen.) 

Someone else can now buy the ticket. You’re not ‘locking’ that seat for the performance. It’s still available to be sold by the theatre after the 15 minute ‘reservation’ expires. If it’s such a busy show, it’ll sell anyway.

Why does this work?

The theatre website sees you using the 2nd browser as someone else trying to buy the single seat.
They block the seat out for 15 minutes for them to buy it.
No one else can buy it during this period. As far as the theatre is concerned, that seat is sold and they now only have 2 left.

To prove this, after you ‘reserve’ the single seat in browser 2, if you go back and search the site in browser 1 for tickets, you will see that there are now only 2 left, not three. You can’t ‘see’ the seat the ‘other person’ is in the process of buying.

(This is the reason you ‘cue up’ the 1st browser with your seat selection ready to go in the instructions above– anyone else looking at the same time will see the two free seats and might grab them before you do)

If some site-developer wises up to this loophole and detects that there are two browsers on the same computer (maybe by checking your IP address rather than a session cookie), simply use your phone to ‘block out’ the single seat you don’t want. Your mobile provider will have a different IP address range to your land-line/ADSL/Cable ISP and you will still look like a different person.

Enjoy the show. You’re welcome.

What does this have to do with ACID/XA transactions???

(The following refers to 'database ACID transactions' this is equally applicable to other ACID/XA transaction systems such as MQ/Messaging, Application Servers such as IBM WebSphere, Mainframe transaction systems such as CICS etc etc)

The ‘reserving the seat for 15 minutes’ is a ‘soft transaction lock’ i.e. putting a marker on that seat to say that it is selected and locked for update and that no-one else can update it (book the seat), or even see that seat to select it.

This is how database row updates work under ACID (Wikipedia) transactions. When you select for update, the rows you want to update are locked until you commit the transaction. Most databases won’t let you lock for 15 minutes though. They do, however, have lock timeouts and will unlock the row (give back the seat) if you take too long!

The ‘I’ in ACID stands for ‘Isolation’. This means that if user 1 is updating the rows in the database, user 2 can’t see those updates until user 1’s transaction is committed.

This is the same as you not being able to see the single seat in the theatre when the ‘someone else’ is booking it.

This does give us a problem in databases. If user 1 has a transaction lock on row 10 and user 2 tries to read row 10, what does user 2 see?

This depends on the transaction read settings in the client and DB engine.
Option 1: User 2 sees the row as it was before user 2 started their transaction
Option 2: User 2 gets a ‘This row is locked’ error. More likely, user 2’s request will wait until user 1’s update has finished. In computer speeds this is rarely more than a few seconds (normally it’s a few milliseconds). After that, they will see the row after user 1 has made their updates.



Thursday, 1 June 2017

Static IP addresses with VMWare Fusion on a Mac

One of the issues with using VMWare fusion is that the IP addresses for your guest OS images can change when you restart them.

Annoyingly, they can also change when you suspend/resume them!

When creating a small 'farm' of machines and linking the hostnames together, this can be a pain in the proverbial!

Luckily Will Warren has the solution here https://willwarren.com/2015/04/02/set-static-ip-address-in-vmware-fusion-7/ - cheers, Will!



Tuesday, 18 April 2017

Life in the Hybrid Lane

(or ‘Can you still be a petrol head if your car plugs into the wall socket?’) 

Due to a combination of:
  • Extreme age – over 10 years
  • Extreme mileage, one at 165,000 miles and another at 275,000 miles
  • Not wonderful fuel economy and fuel around £6/gallon in the UK (Yes, really, if you’re reading this in the USA!),
we decided to trade in our beloved Mercedes E320 CDI and Subaru Impreza WRX estate/wagon. Both gave superb service and will be much missed: We drove all but 75,000 miles of their total in them with hardly any breakdowns (one flat battery, one collapsed suspension strut, couple of blown tyres). I don’t know if I’ll ever own anything as fast as that Subaru again!

So what to choose? I’m not exactly a big ‘green’ fan – if you want to eschew the trappings of modern civilisation, then fine – don’t force it on me. However, if you have a technical solution that gives me the same (or better) quality of life which also fits with your ‘green’ agenda then no problem.

A pure battery car/’EV’? Everything apart from the Tesla models has woeful range. If you can’t get in and do at least 200 miles in one journey when you need to, then no thanks. We looked at the Tesla model ‘S’ but when you need a long journey, with heating/air con on at a decent speed on the motorway (freeway) it still can’t cut it for range we need. And the price! Nice cars though – go check them out – the staff in Bristol, UK were very friendly. The performance is staggering, they have 4WD and who can’t love a car with a ‘ludicrous’ mode?

Hybrid? I had a Toyota Prius as a rental once in the USA for about 6 weeks. Good economy, OK-ish drive but would I want one on my drive at home? No thanks. (I’ve nothing against Toyotas: we did look at the Rav4 Hybrid). What other hybrids are about?

How about the new Mercedes E350e plug-in hybrid? Really nice (go check it out with the new ‘glass cockpit’) but it costs a lot brand new and it only has a 30 mile range on batteries – after which the economy drops off markedly for long-distance motorway miles. For someone who thinks a 150 mile drive is a ‘short hop’ and does a LOT of miles on business, this wasn’t really an option, although I’m still considering it next time around.

For my wife, who normally does round trips of 20/30 miles, a plug-in hybrid is a good option: electric most of the time but with the ability to do long-haul on petrol when needed. Would you want 2 Labradors and driving through muddy fields in an E class though?

Mercedes used to do an E300 diesel hybrid. OK, it doesn’t plug-in but it has the Prius-like regenerative battery technology and it uses the batteries as a KERS style boost when you press the loud pedal. The result is that the 2.2 litre diesel hybrid is actually faster than my old 3.2 litre diesel. It also does a lot more MPG, especially once you’ve got to the end of your motorway cruise and you’re into city traffic. Best of all, it looks and feels like a regular E class Merc. It’s not a ‘green car, there’s just a discrete ‘Hybrid’ badge on the back. The battery is in with the engine and gearbox and you don’t lose any boot (trunk) space.

Did I mention that ‘Mercedes used to do them’? You can get them second hand and they’re not badly priced. I got one four years old with 40K miles from Mercedes in Bristol (I’m prepared to travel to buy cars). Service there was really good BTW: ask for Roy Humphreys.

New Merc, same as the old Merc, but with all the updated toys/electronics, new light/dark leather and 235K less miles on the clock.

So that’s the Merc, what about the Subaru? For that we had to switch religions (if you followed WRC rallying in the McRae/Burns/Makkinen years you’ll know why). We swapped our Subaru for a Mitsubishi! I can feel my membership of scoobynet.co.uk being revoked as I type. . .

The Mitsubishi Outlander PHEV is a plug-in 4X4 SUV hybrid with a claimed 30 mile battery range; but crucially it also has a 45 litre petrol (gas) tank. Run out of battery? No worries, the engine takes over and you pretty much don’t even notice. Run out of fuel? Petrol is available pretty much anywhere – no range anxiety! Worries about the batteries? 8 year warranty (in addition to 5 year on the car).

Best of all they’re dirt cheap used. We picked a 1 year old example up with 13K miles on the clock (with a choice of colours!) under half new price from Masters Mitsubishi of Croydon. Again, service was superb (ask for Matthew) and we were happy to travel to get the good deal.

So, what are they like in practice? What about the claimed mpg? What are the pros and cons? Do you need to trade in your microwave for a camp fire to ‘go green’? Did we sacrifice anything for fuel economy and cheaper car tax?

Easiest is the Merc. It’s an E class with all that goes along with it, including (in my experience) the wonderful Mercedes dealer service. We use Winchester (ask for John in service). It looks like an E class, drives like an E class, has that ‘Aaah, this is nice!’ feel to it when you get in after a long day at the office and gives between 47 and 53 mpg so far in mixed usage.

Just turn the key, hit the loud pedal and go. No hassle and the performance is also lots of fun – the ‘SE” seems to have the AMG suspension and it’s all specced up with COMAND Nav/DVD, sunroof, light leather, through load, voice control etc etc.

If you have (or have had) an E class, it’s one of those. The real eco-benefit is in traffic and stop/start conditions when the hybrid battery really kicks in and the engine switches off. It also does it on the motorway: If you’re coasting downhill, it just kills the engine – watch the rev-counter drop to zero at 70mph! Quite scary! But watch the mpg shoot up at the same time.

What about the Mitsu? Well, it’s not going to match the sub 6 second acceleration of a Prodrive chipped Subaru WRX (even though it’s from the guys who brought you the Evo) but for a 1.8 tonne SUV that’s effectively a 7 seater (think Hyundai Santa Fe / VW Tuareg size) it seems to drive much better than its official performance figures would suggest, although it can run out of steam accelerating at motorway speed. You can corner positively and it’s very drivable – it doesn’t feel like you’ve compromised on fun. It also gives full torque from 0mph so it’s worryingly quick off the line – although only to about 20mph!

It’s also completely silent which is very disconcerting initially. it’ll do the run-silent-on-batteries trick up to 75mph and it is (as Mitsubishi say) not that noticeable when the engine starts. It starts when it needs to and stops when it doesn’t.

No manual intervention required. Two pedals, accelerator and brake. Just drive it like a normal (huge) auto and let the car get on with it.

And we’ve got over 140MPG out of it! Yep, One-Hundred and Forty, not just forty!

OK, that wasn’t just on petrol, we did have to add electricity. We charge it up at home and fully charged it registers about 20 to 23 miles of electric range – which seems pretty accurate in our experience. To charge it up is 10KW of power, which costs us just over £1. Given that petrol is around £6/gallon, then that’s financially 120mpg if you can run it on the batteries alone.

We do some longer runs (We’ve taken it on 500 mile round trips) and the economy really drops off when you don’t charge it up – around 35 to 40 mpg depending on motorways etc, but that’s still not bad for nearly 2 tonnes of SUV. You still get a 300 mile range and petrol is widely available when you run low.

When you’re doing 20 mile/day trips though, it really makes sense. 950 miles out of 30 litres of fuel is really quite astounding. Considering we used to get 30mpg (or less) out of the Subaru, it’s very much lighter on the pocket! And that’s not mentioning the reduction of the road tax from £285 to £0 (it went from £285 to £20 on the Merc)

You get into the habit of plugging it in whenever you’re home (the UK government and Mitsubishi subsidise a dedicated 7Kw charging point at home which does it in about 3 hours, or you can just plug it into a regular 3-pin socket for a 5 hour charge) and just keep topping it off. We can go for days without using any fuel – in fact Mitsubishi tells you to use 20 litres of fuel per month to keep everything flushed through as some people run them purely on batteries. There’s a rumour of someone getting 4000+ miles out of a tank . .

It’s pretty big compared to what we were used to and there is loads of room, especially in the back as the 6th and 7th seats aren’t there due to the batteries. Some reviews have said the cabin is “sparse” and “plasticky”, but it’s got Leather, Sat Nav, Bluetooth/Phone connectivity, DVD player, power seats, sunroof, Xenon lights, voice control – good enough for us and better than our ‘old’ Subaru was. Maybe it might seem “cheap” if you paid £40K for it, but for sub £20K, it’s really not too bad!

Can’t comment on reliability yet as we’ve only had them for a few months. Previous experience with the last Merc was ‘bulletproof’ and I’m assuming Mitsubishi is up there with Subaru build quality. If it’s not, I’ve the balance of a 5 year warranty. Not had to service it yet, so can’t comment on our local Mitsubishi dealer’s (Winchester) service department although their sales dept seemed very friendly when we went looking to buy the car in the first place.

Any regrets? Losing the ‘Turbo nutter’ performance of the ‘Scooby-Doo’ and we’ll also miss the superb service from Simpson’s Subaru in Swindon (ask for Karen). The Merc is a pure upgrade and it’s more and better of the same. The Mitsu is nice to have something ‘different’ – it’s all good so far.

So have we gone ‘green’? Not really, it was a purely economic decision. If you want to change behaviour, incentivise people the right way and see them change – we did. The best bit is when a ‘green’ person yells at me for driving a ‘gas guzzler’ SUV. It’s great to say ‘it’s electric! How is your old junk-mobile saving the planet then?’