Projet

Général

Profil

0001-sql-lock-wcs_meta-during-schema-updates-57017.patch

Benjamin Dauvergne, 16 septembre 2021 19:21

Télécharger (3,35 ko)

Voir les différences:

Subject: [PATCH] sql: lock wcs_meta during schema updates (#57017)

 wcs/sql.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
wcs/sql.py
388 388
    return get_publisher().pgconn
389 389

  
390 390

  
391
def lock_schema():
392
    conn, cur = get_connection_and_cursor()
393
    do_meta_table(conn, cur, insert_current_sql_level=False)
394
    cur.execute('LOCK wcs_meta')
395

  
396

  
391 397
def cleanup_connection():
392 398
    if hasattr(get_publisher(), 'pgconn') and get_publisher().pgconn is not None:
393 399
        get_publisher().pgconn.close()
......
512 518

  
513 519
@guard_postgres
514 520
def do_formdef_tables(formdef, conn=None, cur=None, rebuild_views=False, rebuild_global_views=True):
521
    lock_schema()
522

  
515 523
    if formdef.id is None:
516 524
        return []
517 525

  
......
719 727

  
720 728

  
721 729
def do_formdef_indexes(formdef, created, conn, cur, concurrently=False):
730
    lock_schema()
731

  
722 732
    table_name = get_formdef_table_name(formdef)
723 733
    evolutions_table_name = table_name + '_evolutions'
724 734
    existing_indexes = set()
......
751 761

  
752 762
@guard_postgres
753 763
def do_user_table():
764
    lock_schema()
765

  
754 766
    conn, cur = get_connection_and_cursor()
755 767
    table_name = 'users'
756 768

  
......
864 876

  
865 877

  
866 878
def do_role_table(concurrently=False):
879
    lock_schema()
880

  
867 881
    conn, cur = get_connection_and_cursor()
868 882
    table_name = 'roles'
869 883

  
......
914 928

  
915 929

  
916 930
def do_tracking_code_table():
931
    lock_schema()
932

  
917 933
    conn, cur = get_connection_and_cursor()
918 934
    table_name = 'tracking_codes'
919 935

  
......
949 965

  
950 966

  
951 967
def do_session_table():
968
    lock_schema()
969

  
952 970
    conn, cur = get_connection_and_cursor()
953 971
    table_name = 'sessions'
954 972

  
......
991 1009

  
992 1010

  
993 1011
def do_custom_views_table():
1012
    lock_schema()
1013

  
994 1014
    conn, cur = get_connection_and_cursor()
995 1015
    table_name = 'custom_views'
996 1016

  
......
1039 1059

  
1040 1060

  
1041 1061
def do_snapshots_table():
1062
    lock_schema()
1063

  
1042 1064
    conn, cur = get_connection_and_cursor()
1043 1065
    table_name = 'snapshots'
1044 1066

  
......
1080 1102

  
1081 1103

  
1082 1104
def do_loggederrors_table(concurrently=False):
1105
    lock_schema()
1106

  
1083 1107
    conn, cur = get_connection_and_cursor()
1084 1108
    table_name = 'loggederrors'
1085 1109

  
......
1255 1279

  
1256 1280
@guard_postgres
1257 1281
def do_views(formdef, conn, cur, rebuild_global_views=True):
1282
    lock_schema()
1283

  
1258 1284
    # create new view
1259 1285
    table_name = get_formdef_table_name(formdef)
1260 1286
    view_name = get_formdef_view_name(formdef)
......
1365 1391

  
1366 1392

  
1367 1393
def do_global_views(conn, cur):
1394
    lock_schema()
1368 1395
    # recreate global views
1369 1396
    from wcs.formdef import FormDef
1370 1397

  
......
3511 3538

  
3512 3539
@guard_postgres
3513 3540
def migrate():
3541
    lock_schema()
3542

  
3514 3543
    conn, cur = get_connection_and_cursor()
3515 3544
    sql_level = get_sql_level(conn, cur)
3516 3545
    if sql_level < 0:
3517
-