|
35 | 35 |
|
36 | 36 | # Increment this PATCH version before using `charmcraft publish-lib` or reset
|
37 | 37 | # to 0 if you are raising the major API version
|
38 |
| -LIBPATCH = 22 |
| 38 | +LIBPATCH = 24 |
39 | 39 |
|
40 | 40 | INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles"
|
41 | 41 |
|
@@ -355,6 +355,13 @@ def _generate_database_privileges_statements(
|
355 | 355 | sql.Identifier(user),
|
356 | 356 | )
|
357 | 357 | )
|
| 358 | + statements.append( |
| 359 | + """UPDATE pg_catalog.pg_largeobject_metadata |
| 360 | +SET lomowner = (SELECT oid FROM pg_roles WHERE rolname = '{}') |
| 361 | +WHERE lomowner = (SELECT oid FROM pg_roles WHERE rolname = '{}');""".format( |
| 362 | + user, self.user |
| 363 | + ) |
| 364 | + ) |
358 | 365 | else:
|
359 | 366 | for schema in schemas:
|
360 | 367 | schema = sql.Identifier(schema)
|
@@ -572,15 +579,20 @@ def build_postgresql_parameters(
|
572 | 579 | if parameter in ["date_style", "time_zone"]:
|
573 | 580 | parameter = "".join(x.capitalize() for x in parameter.split("_"))
|
574 | 581 | parameters[parameter] = value
|
575 |
| - shared_buffers_max_value = int(int(available_memory * 0.4) / 10**6) |
| 582 | + shared_buffers_max_value_in_mb = int(available_memory * 0.4 / 10**6) |
| 583 | + shared_buffers_max_value = int(shared_buffers_max_value_in_mb * 10**3 / 8) |
576 | 584 | if parameters.get("shared_buffers", 0) > shared_buffers_max_value:
|
577 | 585 | raise Exception(
|
578 |
| - f"Shared buffers config option should be at most 40% of the available memory, which is {shared_buffers_max_value}MB" |
| 586 | + f"Shared buffers config option should be at most 40% of the available memory, which is {shared_buffers_max_value_in_mb}MB" |
579 | 587 | )
|
580 | 588 | if profile == "production":
|
581 |
| - # Use 25% of the available memory for shared_buffers. |
582 |
| - # and the remaining as cache memory. |
583 |
| - shared_buffers = int(available_memory * 0.25) |
| 589 | + if "shared_buffers" in parameters: |
| 590 | + # Convert to bytes to use in the calculation. |
| 591 | + shared_buffers = parameters["shared_buffers"] * 8 * 10**3 |
| 592 | + else: |
| 593 | + # Use 25% of the available memory for shared_buffers. |
| 594 | + # and the remaining as cache memory. |
| 595 | + shared_buffers = int(available_memory * 0.25) |
584 | 596 | effective_cache_size = int(available_memory - shared_buffers)
|
585 | 597 | parameters.setdefault("shared_buffers", f"{int(shared_buffers/10**6)}MB")
|
586 | 598 | parameters.update({"effective_cache_size": f"{int(effective_cache_size/10**6)}MB"})
|
|
0 commit comments