summaryrefslogtreecommitdiffstats
path: root/lib/prserv
AgeCommit message (Collapse)Author
2014-07-03lib: fix no newline at end of fileRobert Yang
Add a '\n' to the last line of the file to fix: No newline at end of file Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-05-03prserv/db: Avoid fsync() callsRichard Purdie
If the power were to fail, it doesn't matter to us much if the data makes it to disk or not, we'd have other problems. However an fsync() call on a multi build autobuilder is painful so lets avoid them. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-03-28prserv: Fix exit race issuesRichard Purdie
We shouldn't immediately remove the pid file when stopping the server, if we do, this causes a traceback within the server itself which can then hang. Fix this by removing the stale pid file as the last thing we do. Also: * don't printing a new "waiting" line every 0.5 seconds. * make the loop more granular since the user can 'feel' the 0.5 seconds [YOCTO #5984] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-11-18serv.py: Give pr-server up to 5 seconds to commit dataKonrad Scherer
The default value of 0.5 seconds before sending the pr-server a SIGTERM is not enough to guarantee that sqlite has committed all the pr data to the database. By polling the pid to see if it is still running, this allows the pr-server process to shutdown cleanly and finish the final pr data commit. Signed-off-by: Konrad Scherer <Konrad.Scherer@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-08prserv: Ensure data is committedRichard Purdie
In exclusive mode, we need to complete the transaction for writes to make it to the database. Therefore add sync calls to ensure this happens. Autocommit mode is significantly (100 times) slower so caching the data is of significant benefit. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-01prserv/serv: Settle on two threads for optimal performanceRichard Purdie
Using the threading mixin class resulted in large amounts of memory being used by the PR server for no good reason. Using a receiver thread and a thread to do the actual database operations on a single connection gives the same performance with a much saner memory overhead so switch to this. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-01serv/db: Don't use BEGIN/COMMITRichard Purdie
Since we don't support using multiple servers on the same database file, don't use the BEGIN/COMMIT syntax and allow writes to the database to work ~100 times faster with no transaction locking. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-01serv/db: Take an excluside lock on the databaseRichard Purdie
We only support one server using the database at a time so take an exclusive lock and avoid later lock overhead. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-01serv/db: Fix looping upon database locked issuesRichard Purdie
If the database is locked we will get an immediate error indicating so, there is no retry timeout. The looping code is therefore useless, the loop count is near instantly exceeded. Using a time based retry means we can wait a sensible time, then gracefully exit. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-30prserv: Allow 'table is locked' matching for retry loopRichard Purdie
Try and avoid errors like "ERROR: database table is locked: PRMAIN_nohist" by retrying if we see the string "is locked". Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-29prserv/serv: Multithread the serverRichard Purdie
This makes the PR server multithreaded and able to handle multiple connections at once which means its no longer a build bottle neck when serving one connection at a time. I've experimented and database connection for each thread seems to cause the least issues, pushing the contention for sqllite to handle itself. This means moving the db/table connection code into the actual function methods. It doesn't abstract well as a function since we need the db object around for the lifetime of the function as well as the table else we lose the connection. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-29prserv/db: Threading fixesRichard Purdie
Enabling threading for the PRServer causes a number of issues. Firstly is the obtuse error: sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type which is due to the class not being derived from object. See: http://docs.python.org/2/library/sqlite3.html#registering-an-adapter-callable Secondly, we want to enable multithreadded access to the database so we do this when we open it. This opens the way up to multithreading the PR server. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-28serv.py: Fix regression from 972bc43e6d5bJason Wessel
commit 972bc43e6d5b1207b944b3baa8f9805adb35dda7 (serv.py: Fix hang when spawned dynamically with bitbake) introduced a regression, because the wrong patch was submitted. The syntax was incorrect in the original patch. The logger iterator must be used with a call to getLogger(). [YOCTO #5059] Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-28serv.py: Fix hang when spawned dynamically with bitbakeJason Wessel
The PRServer has the possibility to hang indefinitely blocking on a semaphore processing a xmlrpc request to send an event back to the main bitbake instance. This was observed during a "bitbake -e" on a heavily loaded machine and the main bitbake instance and cooker exited before the PRServer emitted its first log. The stack trace is provided below as to show what happens every time a logger.info() is executed in the PRServer. Not only does it write to the stream handler but it also tries to send the event to the main event processor. self._notempty.acquire() self.queue.put(event) _ui_handlers[h].event.send(event) fire_ui_handlers(event, d) fire(record, None) self.emit(record) hdlr.handle(record) self.callHandlers(record) self.handle(record) self._log(INFO, msg, args, **kwargs) (self.dbfile, self.host, self.port, str(os.getpid()))) self.work_forever() pid = self.daemonize() self.prserv.start() singleton.start() self.prhost = prserv.serv.auto_start(self.data) cooker.pre_serve() bb.cooker.server_main(self.cooker, self.main) self.run() code = process_obj._bootstrap() self._popen = Popen(self) self.serverImpl.start() server.detach() server = start_server(servermodule, configParams, configuration) ret = main() It was never intended for the PRServer to send its logs anywhere but its own log file. The event processing is an artifact of how the PRServer was forked and it inherits the event log handlers. The simple fix is to clean up and purge all the log handlers after the fork() but before doing any of the typical PRServer work or logging. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-26server/xmlrpc/prserv: Add sane timeout to default xmlrpc serverRichard Purdie
The standard python socket connect has long timouts which make sense for remote connections but not local things like the PR Service. This adds a timeout parameter to the common xmlrpc server creation function and sets it to a more reasonable 5 seconds. Making the PR server instantly exit is a good way to test the effect of this on bitbake. We can remove the bodged timeout in the PRServer terminate function which has the side effect of affecting global scope. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-23prserv/serv: Fix pid file removalRichard Purdie
Mark Hatle spotted there were pid files being left around. This patch fixes things so the removal function is called correctly, the code contained a typo. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-06-12prserv: Adapt autostart to bitbake-workerRichard Purdie
With the change to bitbake-worker we need to ensure the workers know how to contact the PR service, the magic 0 port and singleton is no longer enough. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-30prserv: Unbreak after bb.server changesRichard Purdie
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-09prserv: Drop StandardError usageRichard Purdie
StandardError doesn't exist in python 3, use Exception instead. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-03prserv/cooker: Handle PRService errors cleanlyRichard Purdie
Current if the PR Service fails to start, bitbake carries on regardless or hangs with no error message. This adds an exception and then handles it correctly so the UIs correctly handle the error and exit cleanly. [YOCTO #4010] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-02-06prserv/serv.py: Fix logging in daemon modeRichard Purdie
In deamon mode we need to ensure the logging module is sending log data to the log file. These changes ensure this happens correctly. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-02-06bitbake: Always use separate process for PR ServiceRichard Purdie
Using the threading module interacts badly with multiprocessing used elsewhere in bitbake under certain machine loads. This was leading to bitbake hanging on Ctrl+C when the PR Server was being used. This patch converts it to always use the daemonize code which then means the threading code isn't required. [YOCTO #3742] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-23prserv: use only PRSERV_HOSTConstantin Musca
- remove PRSERV_PORT variable - use 'hostname:port' as PRSERV_HOST format - use 'localhost:0' for enabling the local PRServer [YOCTO #3744] Signed-off-by: Constantin Musca <constantinx.musca@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-02-01prserv: Do not ping PRService if not requiredLianhao Lu
[YOCTO #1942] Ping the PRService only if PRSERV_HOST and PRSERV_PORT are set. Signed-off-by: Lianhao Lu <lianhao.lu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-01-20prserv: fix import of sqlite3Martin Jansa
* this is used in all other bitbake parts where sqlite3 is used, don't know why it wasn't used here, but it fails e.g. on Gentoo Traceback (most recent call last): File "bin/bitbake", line 39, in <module> from bb import cooker File "lib/bb/cooker.py", line 39, in <module> import prserv.serv File "lib/prserv/serv.py", line 4, in <module> import xmlrpclib,sqlite3 ImportError: No module named sqlite3 Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-01-11bitbake: Automatically start local PR service.Lianhao Lu
[YOCTO #1126] A local PR service will be started and stopped automatically along with the bitbake invocation/ternimation. This local PR service will be started only and if only when the PRSERV_HOST is set to 'localhost' and PRSERV_PORT is set to '0'. When started, the sqlite3 database is stored at "${PERSISTEN_DIR}/prserv.sqlite3" or "${CACHE}/prserv.sqlite3". Signed-off-by: Lianhao Lu <lianhao.lu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-01-11bitbake/PRservice: Added no_hist mode and export/import.Lianhao Lu
[YOCTO #1556] 1. Added the package_arch into the index to the DB table. Because the change in PACKAGE_ARCH will results in different checksum, and it is better to have seperate PR value domains for differnt PACKAGE_ARCH of the same pakcage. 2. Changed the PR service to operate in no history mode. In this mode, the for a given query tuple (version, pkgarch, checksum), the returned value will be the largest among all the values of the same (version, pkgarch). This means the PR value returned can NOT be decremented. 3. Added export function. For each (version, pkgarch) tuple, only the record with the maximum value will be exported. 4. Added import function. The record will only be imported if the imported value is larger than the value stored in the DB with the same (version, pkgarch, checksum) tuple. Signed-off-by: Lianhao Lu <lianhao.lu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-06-15make exception handling syntax consistentScott Garman
Update exception handling syntax to use the modern style: except ExcType as localvar Signed-off-by: Scott Garman <scott.a.garman@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-05-27Add PR service deamon to bitbakeLianhao Lu
Added the initial implementation of the server side PR service. Signed-off-by: Lianhao Lu <lianhao.lu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>