Oracle: dbstart – ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
We ran into an interesting problem when trying to start up an Oracle instance using dbstart whereby we were getting the following error:
-bash-3.2$ dbstart ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener Usage: /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart ORACLE_HOME Processing Database instance "orcl": log file /u01/app/oracle/product/11.2.0/dbhome_1/startup.log
Ignoring the usage message we thought that setting the environment variable was what we needed to do, but…
-bash-3.2$ export ORACLE_HOME_LISTNER=$ORACLE_HOME -bash-3.2$ dbstart ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener Usage: /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart ORACLE_HOME Processing Database instance "orcl": log file /u01/app/oracle/product/11.2.0/dbhome_1/startup.log
We ended up looking at the source of dbstart to see what was going on:
# First argument is used to bring up Oracle Net Listener ORACLE_HOME_LISTNER=$1 if [ ! $ORACLE_HOME_LISTNER ] ; then echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener" echo "Usage: $0 ORACLE_HOME"
The usage message does explain that you’re supposed to call it like this:
-bash-3.2$ dbstart $ORACLE_HOME
But it still seems a bit weird/misleading to me that you’d override the value of a global variable from inside a script which doesn’t suggest that it’s going to do that!
Such is life in Oracle land..
Developer machine automation: Dependencies
As I mentioned in a post last week we’ve been automating the setup of our developer machines with puppet over the last week and one thing that we’ve learnt is that you need to be careful about how you define dependencies.
The aim is to get your scripts to the point where the outcome is reasonably deterministic so that we can have confidence they’re going to work the next we run them.
We noticed two ways in which we haven’t quite achieved determinism yet:
Accidental Dependencies
The first few times that we ran the scripts on top of a vanilla image we were doing it on a virtual machine which had VMware tools installed on it.
We’d forgotten that VMware tools had been installed on those VMs and ran into a problem with Oracle dependencies not being satisfied when we ran puppet on some machines which had CentOS installed directly (i.e. not on a virtual machine).
Those dependencies had been satisfied by our VMware tools installation on the VMs so we didn’t realise that we hadn’t explicitly stated those dependencies, something which we have done now.
External Dependencies
We couldn’t find the Firefox version that we wanted install on the default yum repositories so we created a puppet task which linked to a Firefox RPM on an external server and then installed it.
It worked originally but at some stage over the last couple of weeks the URI was changed as a minor version had been upgraded, breaking our script.
We also came across another way that external dependencies can fail today – if a corporate proxy blocks access to the URL!
We’re trying to get to the stage where we’re only relying on artifacts either coming from a yum repository or an internal repository where we can store any libraries which aren’t available through yum.
Don’t assume determinism
While trying to solve these dependency problems in our puppet scripts I made the mistake of assuming that if the script runs through once and works that it’s always going to be that way in the future.
Since we had achieved that previously in my mind it was impossible for it to fail in future which stopped me from properly investigating why it had stopped working.
Playing around with pomodoros
Over the last 3/4 months I’ve been playing around with the idea of using pomodoros to track all coding/software related stuff that I do outside of work.
I originally started using this technique while I was doing the programming assignments for ml-class because I wanted to know how much time I was spending on it each week and make sure I didn’t run down rabbit holes too often.
One interesting observation that I noticed from keeping the data of these pomodoros was that while during the early programming assignments it would take me 7 or 8 pomodoros to finish, by the end it was down to around 4.
I think this was due to the difficulty of the assignments decreasing as time went on, I didn’t improve that dramatically!
As I mentioned a few weeks ago I’ve also been using pomodoros in combination with a yak stack to make sure I don’t go off track and it’s been interesting applying the technique while trying to solve a problem I’m having with using the Jersey client on Android.
It’s such a fiddly problem and splitting my time into 25 minute slots has forced me to create a plan for what I’m going to try and do in that pomodoro, whether it be ruling out an approach or trying to understand the underlying code that isn’t working.
I haven’t been successful in solving my problem but I’m pretty sure that I’ve spent much less time trying to solve it than I would have otherwise. I can certainly imagine spending hours aimlessly trying things that have no chance of working.
One thing I’ve been experimenting with is reducing the length of the pomodoro to 15 minutes when I know there’s something specific that I want to investigate and I’m fairly sure it won’t take a full length pomodoro.
Previously I would end up just killing time for 10 minutes or just resetting the pomodoro because I didn’t have anything else to do.
I generally enjoy coding much more by applying this time constraint and I think the reason for that is explained by The Progress Principle, which I’m currently reading:
If people are in an excellent mood at the end of the day, it’s a good bet that they have made some progress in their work. If they are in a terrible mood, it’s a good bet that they have had a setback.
To a great extent, inner work life rises and falls with progress and setbacks in the work. This is the progress principle
Using a pomodoro seems to reduce the amount of time that is spent dealing with setbacks and it creates frequent opportunities to discard an approach you’re taking if it’s clear that it’s not going anywhere.
A disadvantage that I’ve sometimes felt when working on the Jersey/Android problem is that I really don’t want to spend 25 minutes working on it because I’ve been getting absolutely nowhere with it for about 6/7 pomodoros now.
I’d rather delude myself that I’m going to magically fix it just by fiddling around with the code for an indeterminate period of time!
In a way constraining coding in this way does take some of the fun out of it as well because it’s now more structured and you tend to have fun when you’re just randomly doing stuff and lose track of time.
On the other hand I probably end up doing a lot more of the stuff I want to do when I constrain it in this way!
Decisions, decisions…
Installing Puppet on Oracle Linux
We’ve been spending some time trying to setup our developer environment on a Oracle Linux 5.7 build and one of the first steps was to install Puppet as we’ve already created scripts which automate the installation of most things.
Unfortunately Oracle Linux builds don’t come with any yum repos configured so when you run the following command…
ls -alh /etc/yum.repos.d/
…you don’t see anything
We eventually realised that there are a list of public yum repositories on the Oracle website, of which we needed to download the definition for Oracle Linux 5 like so:
cd /etc/yum.repos.d wget http://public-yum.oracle.com/public-yum-el5.repo
We then need to edit that file to enable the appropriate repository. In this case we want to enable ol5_u7_base:
[ol5_u7_base] name=Oracle Linux $releasever - U7 - $basearch - base baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL5/7/base/$basearch/ gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-el5 gpgcheck=1 enabled=1
I made the mistake of enabling ol5_u5_base which led to us getting some really weird problems whereby yum got confused as to which version of libselinux we had installed and was therefore unable to install libselinux-ruby as its dependencies weren’t being properly satisfied.
Calling ‘yum list installed’ suggested that we had libselinux 1.33.4.5-7 installed but if we ran ‘yum install libselinux’ then it suggested we already had 1.33.4.5-5 installed. Very confusing!
After trying to uninstall and downgrade libselinux and pretty much destroying the installation in the process, another colleague spotted my mistake.
We also found that we had to add the epel repo which gave us access to some other packages that we needed:
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
After all that was done we were able to run the command to install puppet:
yum install puppet
That installs puppet 2.6.12 as that’s the latest version in that repo. The latest stable version is 2.7.9 but I think we’ll need to hook up a puppet specific repo to get that working.
Application footprint
I recently came across Carl Erickson’s ‘small teams are dramatically more efficient than large teams‘ blog post which reminded me of something which my colleague Ashok suggested as a useful way for determining team size – the application footprint.
As I understand it the application footprint is applicable for an application at a given point in time and determines how many parallel tasks/streams of work we have.
In the case of the project that I’m currently working on there are 3 separate components which need to interact with each other via an API but otherwise are independent.
We can therefore have 3 pairs working – one on each component – and won’t have to worry about them stepping on each other’s toes.
One interesting thing about the application footprint is that it doesn’t stay the same size all the time.
More often than not once a team has gained trust by getting a release out the product owner will start prioritising more independent features which don’t necessarily overlap.
At this stage it might not be such a bad idea to add people to the team if we want to try and finish more quickly.
If we’re already at the point where we have the same number of pairs as parallel pieces of work then adding people is going to be problematic because we’ll struggle to find work for everyone to do.
Stories in the same stream will have dependencies on each other and although it’s theoretically possible to start on something which has a dependency, the likelihood of having to rework it is higher.
One way to get around that problem if we decide that we don’t want to reduce our team size is to have a pair assigned to working on bugs, cross functional requirements such as performance testing/tuning or doing some technical analysis on upcoming stories.
It’s easy enough to remember all this when you’re starting out building an application but I think it’s something that we need to keep in mind so that if there’s pressure to add people to ‘go faster’ then we can determine if that will actually be the case.
As an aside
Obviously there are times when we decide that we’re happy to put more people on a team than it’s footprint might suggest in order to get an overall gain.
For example with 5 pairs we may finish 50 points in a week but if we increase to 10 pairs then perhaps we now get 60 points.
We’ve nearly halved the efficiency of each pair but overall we’ve got a marginal gain which sometimes makes sense. We also need to be aware of the collective unresponsibility that we might introduce by doing this.
Photo courtesy of farlane
Focused Retrospectives: things to watch for
A few weeks ago a slide deck from an Esther Derby presentation on retrospectives was doing the rounds on twitter and one thing that I found interesting in the deck was the suggestion that a retrospective needs to be focused in some way.
I’ve participated in a few focused retrospectives over the past 7/8 months and I think there are some things to be careful about when we decide to focus on something specific rather than just looking back at a time period in general.
Victimisation
In a retrospective about 6 months ago or so we focused on the analysis part of our process as we’d been struggling to know when a story was complete and what exactly its scope was.
The intention wasn’t the victimise the people working in that role but since there were very few of them compared to people in other roles they were forced onto the defensive as people criticised their work.
It was a very awkward retrospective and it felt like a retrospective was probably the wrong place to address the problem.
It might have been better for the analysts to have been given the feedback privately and then perhaps worked on a solution with a smaller group of people.
Looking for a problem when there isn’t one
I had an interesting conversation with a colleague about whether with very focused retrospectives we end up looking for something to change rather than having any specific pain point which necessitates change.
The problem with this is that there’s a thin line between following the status quo because it works and getting complacent and not looking for ways to improve.
It is interesting to keep in mind though that if it doesn’t seem like there is something to change in an area then perhaps that’s the wrong thing to be focusing on at the moment, which nicely leads into…
Let the team choose the area of focus
There can be a tendency in the teams I’ve worked on for people in managementy roles to dictate what the focus of the retrospective will be which makes sense in a way since they may be able to see something which the team can’t.
On the other hand it can mean that we end up focusing on the wrong thing and team members probably won’t be that engaged in the retrospective since they don’t really get to dictate what’s talked about.
Esther points this out out on slide 23 of the presentation – “Choose a focus that reflects what’s going on for the team“. This perhaps can be determined by having a vote before hand based on some topics that seem prominent.
In summary
There’s lots of other useful tips in Esther’s slide deck which are worth having a look at and I’m sure most of the potential problems I’ve listed probably don’t happen when we have a highly skilled/experienced facilitator.
Wireshark: Following HTTP requests/responses
I like using Wireshark to have a look at the traffic going across different interfaces but because it shows what’s happening across the wire by the packet it’s quite difficult to tell what a request/response looked like.
I’ve been playing around with restfulie/Vraptor today so I wanted to be able to see the request/response pair when something wasn’t working.
I didn’t know it was actually possible but this post on StackOverflow describes how.
First we need to select the row which contains any part of our request/response – in this case I just selected the row representing the request – and then we go to the Analyze menu and click ‘Follow TCP Stream’:
We can then see the requests/responses which happened all next to each other:
The keyboard shortcut to get to that menu is ‘Alt-A F’ but for some reason the ‘Alt’ key wasn’t working for me by default so I had to follow the instructions on Francis North’s blog to get it working.
Oracle: exp – EXP-00008: ORACLE error 904 encountered/ORA-00904: “POLTYP”: invalid identifier
I spent a bit of time this afternoon trying to export an Oracle test database so that we could use it locally using the exp tool.
I had to connect to exp like this:
exp user/password@remote_address
And then filled in the other parameters interactively.
Unfortunately when I tried to actually export the specified tables I got the following error message:
EXP-00008: ORACLE error 904 encountered ORA-00904: "POLTYP": invalid identifier EXP-00000: Export terminated unsuccessfully
I eventually came across Oyvind Isene’s blog post which pointed out that you’d get this problem if you tried to export a 10g database using an 11g client which is exactly what I was trying to do!
He explains it like so:
The export command runs a query against a table called EXU9RLS in the SYS schema. On 11g this table was expanded with the column POLTYP and the export command (exp) expects to find this column.
I needed to download the 10g client so that I could use that version of exp instead. I haven’t quite got it working yet but at least it’s a different error to deal with!
Learning Android: Roboguice – Injecting context into PreferenceManager
In my last post I showed how I’d been able to write a test around saved preferences in my app by making use of a ShadowPreferenceManager but it seemed a bit hacky.
I didn’t want to have to do that for every test where I dealt with preferences – I thought it’d be better if I could wrap the preferences in an object of my own and then inject it where necessary.
Another benefit of taking this approach is that the interface of exactly what I’m storing as user preferences.
I wanted the class to be roughly like this:
public class UserPreferences { public String userKey() { return getDefaultSharedPreferences().getString("user_key", ""); } public String userSecret() { return getDefaultSharedPreferences().getString("user_secret", ""); } private SharedPreferences getDefaultSharedPreferences() { return PreferenceManager.getDefaultSharedPreferences(getContextHereSomehow()); } }
Initially it wasn’t entirely obvious how I could get a Context to pass to getDefaultSharedPreferences but I came across a blog post explaining how to do it.
What we need to do is inject a Context object via the constructor of the class and decorate the constructor with the @Inject attribute so that Roboguice will resolve the dependency:
public class UserPreferences { private Context context; @Inject public UserPreferences(Context context) { this.context = context; } public SharedPreferences getDefaultSharedPreferences() { return PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); } public String userKey() { return getDefaultSharedPreferences().getString("user_key", ""); } public String userSecret() { return getDefaultSharedPreferences().getString("user_secret", ""); } }
We never have to explicitly setup a binding for Context in our Roboguice because it’s already been done for us in RoboModule which is instantiated by RoboApplication which we extend like so:
public class TweetBoardApplication extends RoboApplication { private Module module = new RobolectricSampleModule(); @Override protected void addApplicationModules(List<Module> modules) { modules.add(module); } public void setModule(Module module) { this.module = module; } }
We then hook TweetBoardApplication up in the AndroidManifest.xml file like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.pivotallabs" android:versionCode="1" android:versionName="1.0"> <application android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar" android:icon="@drawable/app_icon" android:name="TweetBoardApplication"> </application> </manifest>
And that’s it!
Learning Android: Robolectric – Testing details got saved to SharedPreferences
I’ve been writing some tests around an app I’ve been working on using the Robolectric testing framework and one thing I wanted to do was check that an OAuth token/secret were being saved to the user’s preferences.
The code that saved the preferences looked like this:
public class AuthoriseWithTwitterActivity extends RoboActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(intent); ... save("fakeToken", "fakeSecret"); ... } private void save(String userKey, String userSecret) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); SharedPreferences.Editor editor = settings.edit(); editor.putString("user_key", userKey); editor.putString("user_secret", userSecret); editor.commit(); } }
This is an outline of what I wanted to do in the test:
@RunWith(InjectedTestRunner.class) public class AwesomeTest { @Test public void shouldSaveOAuthDetails() { activity.onCreate(null); ShadowIntent shadowIntent = shadowOf(activity).getNextStartedActivity(); // Get SharedPreferences and check 'fakeToken' and 'fakeSecret' are stored. } }
In Robolectric it’s possible to replace classes with shadow versions of themselves which get used in the test so I first created a shadow version of PreferenceManager:
@Implements(PreferenceManager.class) public class ShadowPreferenceManager { private static SharedPreferences preferences = new TestSharedPreferences(new HashMap<String, Map<String, Object>>(), "__default__", Context.MODE_PRIVATE); @Implementation public static SharedPreferences getDefaultSharedPreferences(Context context) { return preferences; } public static void reset() { preferences = new TestSharedPreferences(new HashMap<String, Map<String, Object>>(), "__default__", Context.MODE_PRIVATE); } }
I had to make preferences a static variable here so that it’ll retain state. It’s a bit hacky but it’ll do for now.
Then to hook it up I had to change my test to read like this:
@RunWith(InjectedTestRunner.class) public class AwesomeTest { @Test public void shouldSaveOAuthDetails() { Robolectric.bindShadowClass(ShadowPreferenceManager.class); activity.onCreate(null); ShadowIntent shadowIntent = shadowOf(activity).getNextStartedActivity(); SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity); assertThat(defaultSharedPreferences.getString("user_key", ""), equalTo("fakeToken")); assertThat(defaultSharedPreferences.getString("user_secret", ""), equalTo("fakeSecret")); ShadowPreferenceManager.reset(); } }
The InjectedTestRunner class used here is pretty much like the one in the Robolectric code base.
There is actually a ShadowPreferenceManager in the Robolectric library but it doesn’t seem to store preferences anywhere as far as I can tell so it wasn’t quite what I wanted.