All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pseudo_db: Flush DB if there is a shutdown request
@ 2021-09-25  9:35 Richard Purdie
  2021-09-25 14:08 ` [OE-core] " Khem Raj
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Purdie @ 2021-09-25  9:35 UTC (permalink / raw)
  To: openembedded-core; +Cc: seebs

We have some challenges in ensuring the pseudo database is flushed to disk
in things like docker containers since the processes can be killed with no
warning at container termination. Rightly or wrongly, we need to handle this
better.

There is no current way to flush the DB but there is a shutdoen request
mechanism. Whilst we can't force a shutdown from bitbake due to the multiple
connected clients and the existing 3s shutdown isn't enough, we can take the
hint to flush the DB at this time. Further writes are unlikely.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 pseudo_db.c     | 2 +-
 pseudo_db.h     | 1 +
 pseudo_server.c | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/pseudo_db.c b/pseudo_db.c
index 6c48cc8..14bafcb 100644
--- a/pseudo_db.c
+++ b/pseudo_db.c
@@ -399,7 +399,7 @@ signed_ino(ino_t ino) {
 
 #ifdef USE_MEMORY_DB
 
-static void
+void
 pdb_backup() {
         sqlite3_backup *pBackup;
         /* no point in doing this if we don't have a database to back up,
diff --git a/pseudo_db.h b/pseudo_db.h
index 5a4aa59..9d01232 100644
--- a/pseudo_db.h
+++ b/pseudo_db.h
@@ -26,6 +26,7 @@ typedef struct {
 	char *program;
 } log_entry;
 
+extern void pdb_backup(void);
 extern int pdb_maybe_backup(void);
 extern int pdb_cancel_unlink_file(pseudo_msg_t *msg);
 extern int pdb_did_unlink_file(char *path, pseudo_msg_t *msg, int deleting);
diff --git a/pseudo_server.c b/pseudo_server.c
index 84cef05..815c76b 100644
--- a/pseudo_server.c
+++ b/pseudo_server.c
@@ -568,6 +568,7 @@ serve_client(int i) {
 				}
 				in->pathlen = (s - response_path) + 1;
 				/* exit quickly once clients go away, though */
+                               pdb_backup();
 				pseudo_server_timeout = 3;
 			} else {
 				in->type = PSEUDO_MSG_ACK;
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [OE-core] [PATCH] pseudo_db: Flush DB if there is a shutdown request
  2021-09-25  9:35 [PATCH] pseudo_db: Flush DB if there is a shutdown request Richard Purdie
@ 2021-09-25 14:08 ` Khem Raj
  0 siblings, 0 replies; 2+ messages in thread
From: Khem Raj @ 2021-09-25 14:08 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core; +Cc: seebs



On 9/25/21 2:35 AM, Richard Purdie wrote:
> We have some challenges in ensuring the pseudo database is flushed to disk
> in things like docker containers since the processes can be killed with no
> warning at container termination. Rightly or wrongly, we need to handle this
> better.
> 
> There is no current way to flush the DB but there is a shutdoen request

typo shutdoen/shutdown

> mechanism. Whilst we can't force a shutdown from bitbake due to the multiple
> connected clients and the existing 3s shutdown isn't enough, we can take the
> hint to flush the DB at this time. Further writes are unlikely.
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>   pseudo_db.c     | 2 +-
>   pseudo_db.h     | 1 +
>   pseudo_server.c | 1 +
>   3 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/pseudo_db.c b/pseudo_db.c
> index 6c48cc8..14bafcb 100644
> --- a/pseudo_db.c
> +++ b/pseudo_db.c
> @@ -399,7 +399,7 @@ signed_ino(ino_t ino) {
>   
>   #ifdef USE_MEMORY_DB
>   
> -static void
> +void
>   pdb_backup() {
>           sqlite3_backup *pBackup;
>           /* no point in doing this if we don't have a database to back up,
> diff --git a/pseudo_db.h b/pseudo_db.h
> index 5a4aa59..9d01232 100644
> --- a/pseudo_db.h
> +++ b/pseudo_db.h
> @@ -26,6 +26,7 @@ typedef struct {
>   	char *program;
>   } log_entry;
>   
> +extern void pdb_backup(void);
>   extern int pdb_maybe_backup(void);
>   extern int pdb_cancel_unlink_file(pseudo_msg_t *msg);
>   extern int pdb_did_unlink_file(char *path, pseudo_msg_t *msg, int deleting);
> diff --git a/pseudo_server.c b/pseudo_server.c
> index 84cef05..815c76b 100644
> --- a/pseudo_server.c
> +++ b/pseudo_server.c
> @@ -568,6 +568,7 @@ serve_client(int i) {
>   				}
>   				in->pathlen = (s - response_path) + 1;
>   				/* exit quickly once clients go away, though */
> +                               pdb_backup();
>   				pseudo_server_timeout = 3;
>   			} else {
>   				in->type = PSEUDO_MSG_ACK;
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#156343): https://lists.openembedded.org/g/openembedded-core/message/156343
> Mute This Topic: https://lists.openembedded.org/mt/85857567/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-25 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-25  9:35 [PATCH] pseudo_db: Flush DB if there is a shutdown request Richard Purdie
2021-09-25 14:08 ` [OE-core] " Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.