summaryrefslogtreecommitdiff
path: root/client/src/leap/soledad/client/encdecpool.py
AgeCommit message (Collapse)Author
2016-12-12[refactor] remove encdecpool, finallyKali Kaneko
2016-12-12[refactor] remove encryption poolKali Kaneko
2016-12-12[refactor] remove decpoolVictor Shyba
It's not being used
2016-09-22[style] standardize log messagesdrebs
2016-09-22[feat] centralize logging and use twisted.logger by defaultdrebs
2016-08-23[doc] improve SQLITE_MAX_VARIABLE_NUMBER commentsVictor Shyba
2016-08-22[bug] limit pool comnsumption to 900 docsVictor Shyba
This was discovered during load tests: Trying to process more than 999 docs triggers an error on SQLite due a select query not supporting 999 values to query.
2016-08-02[test] avoid race condition on test_processing_orderVictor Shyba
test_processing_order aims to check that unordered docs wont be processed, but if we let the pool start and advance Twisted LoopingCall clock right before calling the processing method manually, the process method will run concurrently and cause a race condition issue.
2016-06-22[style] pep8Kali Kaneko
2016-06-15[bug] move the decryption to a threadpool tooKali Kaneko
2016-06-06[bug] ensures docs_received table has the sync_id columnNavaL
For the case where the user already has data synced, this commit will migrate the docs_received table to have the column sync_id. That is required by the refactoring in the previous commits.
2016-06-06[bug] delete all docs on start and ensure isolationVictor Shyba
Docs created from one failed sync would be there for the next one, possibly causing a lot of hard to find errors. This commit adds a sync_id field to track each sync documents isolated and cleans up the pool on start instead of constructor.
2016-06-06[refactor] encdecpool queries and testingVictor Shyba
This commit adds tests for doc ordering and encdecpool control (start/stop). Also optimizes by deleting in batch and checking for a sequence in memory before asking the local staging for documents.
2016-06-06[refactor] bye multiprocessing poolVictor Shyba
This commit removes the multiprocessing pool and gives a step closer to make encdecpool simpler. Download speed is now at a constant rate, CPU usage lower and reactor responding fast when running with a HTTP server like Pixelated.
2016-01-21[Fix] slow IO-bound calls block reactorVictor Shyba
- Move them to a thread so reactor can continue processing e.g. http requests
2015-12-01[style] fix pep8Victor Shyba
2015-12-01[bug] concurrency bug while querying and insertingVictor Shyba
This line was missing an yield and without it we end up inserting a document that is being retrieved and bad things happen. This is the core fix from yesterday debugging session. During sequential syncs the pool was inserting and querying at the same time and sometimes repeating or failing to delete documents.
2015-12-01[bug] fire callback after reseting instance varsVictor Shyba
If we reset the vars after firing the finish callback, other thread can pick up a dirty state on due concurrency.
2015-09-16[bug] review some of the close methodsVictor Shyba
We are getting "too many files open" while running tests with 1024 max files open. This is a leak from close methods. Some of them should be fixed on this commit, but further investigation may be necessary.
2015-08-19[style] pep8 cleanupsKali Kaneko
2015-08-19[bug] wait for db init on sync decrypter pooldrebs
Previous to this modification, the initialization of the sync decrypter pool could happen concurrently with other database operations. That could cause the pool to hang because it could be waiting for something that was mistakenly deleted because of the wrong order of database operations. This commit implements a standard which we already use in leap.keymanager and leap.mail which makes some methods wait for the initialization operation before they are actually called. Closes: #7386
2015-08-12[bug] changes multiprocessing.Queue to Twisted'sVictor Shyba
multiprocessing.Queue is suitable for process communication, but its not the ideal for a reactor model. This commit changes it to DeferredQueue, where consumers and producers doesnt block and Twisted can handle them better.
2015-08-12[bug] Encdecpool won't explode if stopped twiceBruno Wagner
The encryption pool could be stopped twice and would break on the second attempt because it deletes the encryption queue variable. Added a condition to make sure it only deletes the encryption queue if it exists, making it more idempotent
2015-08-04[test] add test for many documents decryptiondrebs
2015-08-04[feat] add running state method to enc/dec poolsdrebs
2015-08-04[refactor] standardize start/stop of enc/dec poolsdrebs
* change close method name to stop * add start/stop methods to both enc/dec clases * remove any delayed calls on pool shutdown
2015-07-27[bug] avoid double decryption of documentsdrebs
Because of how the incoming document queue is implemented, it could be the case that a document was sent to async decryption queue more than once. This commit creates a list of documents to be decrypted, so we avoid sending the same document to the queue more than once.
2015-07-23[bug] move sync db and encpool creation to apidrebs
Deferred encryption was disabled because the soledad u1db wrapper for adbapi did not correctly udated the parameter that controls it. Also, it did not contain the encrypter pool. This commit moves the sync db and encrypt pool to the main api, so they can be passed to the wrapper and deferred encryption can work.
2015-07-22[refactor] use a deferred to signal when SyncDecriptionPool has finishedRuben Pollan
It makes the code simpler and clearer to use a deferred instead of having to pull on 'has_finished'. - Related: #7234
2015-06-15[style] minor style fixes for correctionKali Kaneko
after suggestions in the review
2015-06-15[refactor] use twisted logging facility to log failureKali Kaneko
2015-06-15[bug] allow reuse of decr poolKali Kaneko
2015-06-03[feature] increase the async encryption perioddrebs
When async decrypting, we want to finish as fast as possible. When encrypting, though, we don't have such a rush. With an encryption loop period of 2 seconds, we're able to encrypt 30 documents in one minute (the current bitmask client sync period), which is meaningful: should moderatelly use the processor while not syncing and relief from some work when actually syncing.
2015-06-03[bug] do not block when getting doc for async encdrebs
Previous to this change, the actual encryption method used to run on its own thread. When the close method was called from another thread, the queue could be deleted after the encryption method loop had started, but before the queue was checked for new items. By removing that thread and moving the encryption loop to the reactor, that race condition should disappear. Closes: #7088.
2015-06-03[bug] use exception from correct moduledrebs
Queue exceptions are not in multiprocessing.Queue module, but in plain Queue instead.
2015-06-03[bug] use correct sync enc pool queue attributedrebs
2015-05-26[bug] Empty comes from QueueVictor Shyba
When handling this exception Python got lost because the import was incorrect. Queue.Empty comes from Queue, not from multiprocessing.Queue
2015-05-22[refactor] remove inline enc/dec from client pooldrebs
The whole idea of the encrypter/decrypter pool is to be able to use multiple cores to allow parallel encryption/decryption. Previous to this commit, the encryptor/decryptor pools could be configured to not use workers and instead do encryption/decryption inline. That was meant for testing purposes and defeated the purpose of the pools. This commit removes the possibility of inline encrypting/decrypting when using the pools. It also refactors the enc/dec pool code so any failures while using the pool are correctly grabbed and raised to the top of the sync deferred chain.
2015-05-21[refactor] remove unneeded proxy for insert_doc_cbdrebs
When we initialized the async decrypter pool in the target's init method we needed a proxy to ensure we could update the insert doc callback with the correct method later on. Now we initialize the decrypter only when we need it, so we don't need this proxy anymore. This commit removes the unneeded proxy.
2015-05-20[bug] ensure async decryption failures are loggeddrebs
We have to make sure any failures in asynchronous decryption code is grabbed and properly transmitted up the deferred chain so it can be logged. This commit adds errbacks in the decryption pool that grab any failure and a check on the http target the failure if that is the case.
2015-05-20[feature] ensure reactor stops on client db scriptdrebs
2015-05-20[feature] use twisted.web.client in client syncdrebs
This change uses twisted deferreds for the whole syncing process and paves the way to implementing other transport schemes. It removes a lot of threaded code that used locks and was very difficult to maintain, and lets twisted to the dirty work. Furthermore, all blocking network i/o is now handled asynchronously by the twisted. This commit removes the possibility of interrupting a sync, and we should reimplement it using cancellable deferreds if we need it.
2015-05-20[feature] use twisted adbapi for async encryptiondrebs
The access to the sync db was modified to use twisted.enterprise.adbapi, but only the asynchronous decryption of incoming documents during sync was adapted. This commit modifies the asynchornous encryption of documents to also use the adbapi for accessing the sync db.
2015-05-20[bug] fix order of insertion of decrypted docsdrebs
This commit actually does some different things: * When doing asynchronous decryption of incoming documents in soledad client during a sync, there was the possibility that a document corresponding to a newer generation would be decrypted and inserted in the local database before a document corresponding to an older generation. When this happened, the metadata about the target database (i.e. its locally-known generation) would be first updated to the newer generation, and then an attempt to insert a document corresponding to an older generation would cause the infamous InvalidGeneration error. To fix that we use the sync-index information that is contained in the sync stream to correctly find the insertable docs to be inserted in the local database, thus avoiding the problem described above. * Refactor the sync encrypt/decrypt pool to its own file. * Fix the use of twisted adbapi with multiprocessing. Closes: #6757.