preparecampaign psycopg2.IntegrityError: null value in column "id" violates not-null constraint

Bug #396985 reported by Daniel Bültmann
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
openWNS Wrowser
Triaged
High
Unassigned

Bug Description

There is a problem with the preparecampaign plugin for playground.py. Both questions below describe the problem.

https://answers.launchpad.net/openwns-wifimac/+question/74899
https://answers.launchpad.net/openwns-application/+question/76315

Here at ComNets we were not able to directly reproduce the error. We must check if it is a problem with the database creation as Maciej suggested. If it is the case we need to join the database creation with the preparesimcampaign plugin and provide much better error handling and reporting.

I filed these problems as a bug because (at least) the reporting is much to cryptic and does not give any hint on the "real" source of the problem.

description: updated
Revision history for this message
Hendrik (mostricht) wrote :

Hi everybody,
i am pretty sure, the bug/problem as described in the two links above is solved by now!

But first things first...

1.)
There is a bug in the docu:
When installing the wrowser, section "Adding the wrowser-plugin into playground.py" (http://docs.openwns.org/gettingStarted/wrowser.html), there is a wrowser missing!
Assuming the [path to the wrowser] is the same as above in [AdditionalPluginPaths], an additional "wrowser" has to be added to the pythonpath (at least on my machine...)

export PYTHONPATH=${PYTHONPATH}:[path to the wrowser]/wrowser

2.)
Postgresql version <= 8.2.11 works fine, whereas version 8.3.xx doesn't.
Downgrading helps!

3.)
There is a major bug in "campaignConfiguration.py" in the folder "myOpenWNS/tests/system/wifimac-tests/PyConfig/experiment1".
According to the UserGuide (http://docs.openwns.org/usersGuide/modules/dll/wifimac/experiment1.html) this file needs to be copied into the simulations directory "myFirstCampaign/experiment1" (ot whatever you have called your campaign).
Line 50 says "from pywns.simdb.Parameters import Parameters, Bool, Int, Float, String" - this is the root of all evil :-)

Change this line to "from wrowser.simdb.Parameters import Parameters, Bool, Int, Float, String" or just pywns to wrowser everything is fine!

Don't know if the other experiment files exhibit this bug too...

4.)
And now for something completely different...
You could add a little hint in the docu, section "Adding a database user, 5" when executing the "./createUser.py".
A user is created according to the current user, e.g. if you are logged in as root, a user named root is created. To create a user named postgres, you have to be logged in as postgres by tipping "su postgres". According to the docu, after having typed "exit" in section 4, you are back to the roots...

Revision history for this message
Daniel Bültmann (daniel.bueltmann) wrote : Re: [openWNS-bugsquad] [Bug 396985] Re: preparecampaign psycopg2.IntegrityError: null value in column "id" violates not-null constraint

Hi Hendrik,

finally you got it up and running. Thank you for your help in making it
work on your platform.
I have some comments and questions on your report.

to 1) I filed a new bug and will fix it asap.
https://bugs.launchpad.net/bugs/397076

to 2) Is it true that even when you did step 3 that it does not work
with 8.3.xx ? Is the problem still the same then? Sooner or later we
need to be able to work with the new version. The next distribution
update will make it necessary.

to 3) I moved most of the database related stuff from PyWNS to wrowser
some time ago. It seems that this was not done consistently. There
should be only
one place where to find these files.

to 4) I totally agree, but I would propose a different solution.
    The script should take arguments and do proper error reporting and
console logging. Instead of implicitly assuming the current user, using
a default
    password, default database name and host, it should use command line
options and or interactive queries to the user. It could also be very
well integrated with the createcampaign plugin.

I would be very grateful if you could help us to shed some light on
topic 2 so we can determine the problem with postgresql 8.3.xx .

Best Regards,
  Daniel

Hendrik wrote:
> Hi everybody,
> i am pretty sure, the bug/problem as described in the two links above is solved by now!
>
> But first things first...
>
> 1.)
> There is a bug in the docu:
> When installing the wrowser, section "Adding the wrowser-plugin into playground.py" (http://docs.openwns.org/gettingStarted/wrowser.html), there is a wrowser missing!
> Assuming the [path to the wrowser] is the same as above in [AdditionalPluginPaths], an additional "wrowser" has to be added to the pythonpath (at least on my machine...)
>
> export PYTHONPATH=${PYTHONPATH}:[path to the wrowser]/wrowser
>
> 2.)
> Postgresql version <= 8.2.11 works fine, whereas version 8.3.xx doesn't.
> Downgrading helps!
>
> 3.)
> There is a major bug in "campaignConfiguration.py" in the folder "myOpenWNS/tests/system/wifimac-tests/PyConfig/experiment1".
> According to the UserGuide (http://docs.openwns.org/usersGuide/modules/dll/wifimac/experiment1.html) this file needs to be copied into the simulations directory "myFirstCampaign/experiment1" (ot whatever you have called your campaign).
> Line 50 says "from pywns.simdb.Parameters import Parameters, Bool, Int, Float, String" - this is the root of all evil :-)
>
> Change this line to "from wrowser.simdb.Parameters import Parameters,
> Bool, Int, Float, String" or just pywns to wrowser everything is fine!
>
> Don't know if the other experiment files exhibit this bug too...
>
> 4.)
> And now for something completely different...
> You could add a little hint in the docu, section "Adding a database user, 5" when executing the "./createUser.py".
> A user is created according to the current user, e.g. if you are logged in as root, a user named root is created. To create a user named postgres, you have to be logged in as postgres by tipping "su postgres". According to the docu, after having typed "exit" in section 4, you are back to the roots...
>
>

Changed in openwns-wrowser:
importance: Undecided → High
status: New → Incomplete
Revision history for this message
Hendrik (mostricht) wrote :

to 2)
i downgraded to SQL 8.2 before i fixed 3)
i will try and check this tomorrow and report it to you!

to 4)
great idea, this would be the first class solution!

regards
hendrik

Revision history for this message
Sebastian Max (smx-comnets) wrote : Re: [openWNS-bugsquad] [Bug 396985] Re: preparecampaign psycopg2.IntegrityError: null value in column "id" violates not-null constraint

Hi all,

> to 1) I filed a new bug and will fix it asap.
> https://bugs.launchpad.net/bugs/397076
Fixed, commited, Done.

> to 3) I moved most of the database related stuff from PyWNS to wrowser
> some time ago. It seems that this was not done consistently. There
> should be only
> one place where to find these files.
Imports are changed, bugfix is commited.

> to 4) I totally agree, but I would propose a different solution.
> The script should take arguments and do proper error reporting and
> console logging. Instead of implicitly assuming the current user, using
> a default
> password, default database name and host, it should use command line
> options and or interactive queries to the user. It could also be very
> well integrated with the createcampaign plugin.
I have submitted an intermediate fix that aborts the operation if the
user is "root" or "postgres" - normal user rights are sufficient for the
script, and . I also agree with Daniel, but this takes more time to do...

BR,
Sebastian

Revision history for this message
Hendrik (mostricht) wrote :

Back to topic 2)

Fixing the bug in campaignConfiguration.py does not effect the database problem in ./playground.py preparecampaign as it is executed prior to playground.
Hence i assume, downgrading to 8.2.x or modifiy the generation of the id in 8.3 are the only possible approach...

Revision history for this message
Daniel Bültmann (daniel.bueltmann) wrote :

Dear Hendrik,

thank you for the verfication. So this is an independent bug and we should treat it that way. Would you be so kind to file a separate bug report for the postgresql issue? Please include the error description in this new bug.

Still we also need to find someone to fix this problem. Any volunteers?

Thanks,
  Daniel

Revision history for this message
Daniel Bültmann (daniel.bueltmann) wrote :

Dear Hendrik,

sorry. I got confused. I think this bug report should remain as it is. It is not incomplete anymore. I will create a blueprint of 4) so we can keep track of this separately. So please leave all as it is.

Thanks for your support!

  Daniel

Changed in openwns-wrowser:
status: Incomplete → Triaged
Revision history for this message
Hendrik (mostricht) wrote :

Hi everybody,
I just discovered that postgresql 8.3.10 works just fine!

So there is no need downgrading to 8.2.xx any more...

BR

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.