Compare commits

..

3 Commits

Author SHA1 Message Date
Vadim Kharitonov
4e17ce654e Revert timescaledb to 2.10.1 for pg14 and pg15 2023-12-06 15:26:11 +01:00
Vadim Kharitonov
bf9ac7d721 Revert "[Compute] Update timescaledb to 2.13.0"
This reverts commit 66ea98f2e5.
2023-12-06 15:25:08 +01:00
Christian Schwarz
987c9aaea0 virtual_file: fix the metric for close() calls done by VirtualFile::drop (#6051)
Before this PR we would inc() the counter for `Close` even though the
slot's FD had already been closed.

Especially visible when subtracting `open` from `close+close-by-replace`
on a system that does a lot of attach and detach.

refs https://github.com/neondatabase/cloud/issues/8440
refs https://github.com/neondatabase/cloud/issues/8351
2023-12-06 12:05:28 +00:00
4 changed files with 31 additions and 40 deletions

View File

@@ -387,10 +387,20 @@ COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
ARG PG_VERSION
ENV PATH "/usr/local/pgsql/bin:$PATH"
RUN apt-get update && \
RUN case "${PG_VERSION}" in \
"v14" | "v15") \
export TIMESCALEDB_VERSION=2.10.1 \
export TIMESCALEDB_CHECKSUM=6fca72a6ed0f6d32d2b3523951ede73dc5f9b0077b38450a029a5f411fdb8c73 \
;; \
*) \
export TIMESCALEDB_VERSION=2.13.0 \
export TIMESCALEDB_CHECKSUM=584a351c7775f0e067eaa0e7277ea88cab9077cc4c455cbbf09a5d9723dce95d \
;; \s
esac && \
apt-get update && \
apt-get install -y cmake && \
wget https://github.com/timescale/timescaledb/archive/refs/tags/2.13.0.tar.gz -O timescaledb.tar.gz && \
echo "584a351c7775f0e067eaa0e7277ea88cab9077cc4c455cbbf09a5d9723dce95d timescaledb.tar.gz" | sha256sum --check && \
wget https://github.com/timescale/timescaledb/archive/refs/tags/${TIMESCALEDB_VERSION}.tar.gz -O timescaledb.tar.gz && \
echo "${TIMESCALEDB_CHECKSUM} timescaledb.tar.gz" | sha256sum --check && \
mkdir timescaledb-src && cd timescaledb-src && tar xvzf ../timescaledb.tar.gz --strip-components=1 -C . && \
./bootstrap -DSEND_TELEMETRY_DEFAULT:BOOL=OFF -DUSE_TELEMETRY:BOOL=OFF -DAPACHE_ONLY:BOOL=ON -DCMAKE_BUILD_TYPE=Release && \
cd build && \

View File

@@ -610,9 +610,11 @@ impl Drop for VirtualFile {
slot.recently_used.store(false, Ordering::Relaxed);
// there is also operation "close-by-replace" for closes done on eviction for
// comparison.
STORAGE_IO_TIME_METRIC
.get(StorageIoOperation::Close)
.observe_closure_duration(|| drop(slot_guard.file.take()));
if let Some(fd) = slot_guard.file.take() {
STORAGE_IO_TIME_METRIC
.get(StorageIoOperation::Close)
.observe_closure_duration(|| drop(fd));
}
}
}
}

View File

@@ -19,6 +19,7 @@
#include "access/xlog.h"
#include "access/xlogutils.h"
#include "storage/buf_internals.h"
#include "storage/lwlock.h"
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
#include "c.h"
@@ -36,8 +37,6 @@
#include "walproposer.h"
#include "neon_utils.h"
#include <pthread.h>
#define PageStoreTrace DEBUG5
#define RECONNECT_INTERVAL_USEC 1000000
@@ -70,7 +69,7 @@ int max_reconnect_attempts = 60;
typedef struct
{
pthread_rwlock_t lock;
LWLockId lock;
pg_atomic_uint64 update_counter;
char pageserver_connstring[MAX_PAGESERVER_CONNSTRING_SIZE];
} PagestoreShmemState;
@@ -106,10 +105,10 @@ AssignPageserverConnstring(const char *newval, void *extra)
{
if(!PagestoreShmemIsValid())
return;
pthread_rwlock_wrlock(&pagestore_shared->lock);
LWLockAcquire(pagestore_shared->lock, LW_EXCLUSIVE);
strlcpy(pagestore_shared->pageserver_connstring, newval, MAX_PAGESERVER_CONNSTRING_SIZE);
pg_atomic_fetch_add_u64(&pagestore_shared->update_counter, 1);
pthread_rwlock_unlock(&pagestore_shared->lock);
LWLockRelease(pagestore_shared->lock);
}
static bool
@@ -120,24 +119,15 @@ CheckConnstringUpdated()
return pagestore_local_counter < pg_atomic_read_u64(&pagestore_shared->update_counter);
}
/* Returns true if the connstring has changed and false if not */
static bool
static void
ReloadConnstring()
{
if(!PagestoreShmemIsValid())
return false;
pthread_rwlock_rdlock(&pagestore_shared->lock);
if(strcmp(local_pageserver_connstring, pagestore_shared->pageserver_connstring) == 0)
{
pthread_rwlock_unlock(&pagestore_shared->lock);
return false;
}
return;
LWLockAcquire(pagestore_shared->lock, LW_SHARED);
strlcpy(local_pageserver_connstring, pagestore_shared->pageserver_connstring, sizeof(local_pageserver_connstring));
pagestore_local_counter = pg_atomic_read_u64(&pagestore_shared->update_counter);
pthread_rwlock_unlock(&pagestore_shared->lock);
return true;
LWLockRelease(pagestore_shared->lock);
}
static bool
@@ -300,6 +290,7 @@ pageserver_disconnect(void)
*/
if (connected)
{
neon_log(LOG, "dropping connection to page server due to error");
PQfinish(pageserver_conn);
pageserver_conn = NULL;
connected = false;
@@ -320,12 +311,8 @@ pageserver_send(NeonRequest * request)
if(CheckConnstringUpdated())
{
bool should_disconnect = ReloadConnstring();
if(should_disconnect)
{
neon_log(LOG, "pageserver_send disconnect because connstring changed");
pageserver_disconnect();
}
pageserver_disconnect();
ReloadConnstring();
}
/* If the connection was lost for some reason, reconnect */
@@ -497,12 +484,7 @@ PagestoreShmemInit(void)
&found);
if(!found)
{
pthread_rwlockattr_t attr;
pthread_rwlockattr_init(&attr);
pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
pthread_rwlock_init(&pagestore_shared->lock, &attr);
pthread_rwlockattr_destroy(&attr);
pagestore_shared->lock = &(GetNamedLWLockTranche("neon_libpagestore")->lock);
pg_atomic_init_u64(&pagestore_shared->update_counter, 0);
AssignPageserverConnstring(page_server_connstring, NULL);
}

View File

@@ -60,10 +60,7 @@ def test_change_pageserver(neon_env_builder: NeonEnvBuilder):
execute("SELECT count(*) FROM foo")
assert fetchone() == (100000,)
# Reconfigure it using the same connstring just to make sure nothing breaks
# as we have special handling for if the connstring doesn't change
for _ in range(5):
endpoint.reconfigure(pageserver_id=alt_pageserver_id)
endpoint.reconfigure(pageserver_id=alt_pageserver_id)
# Verify that the neon.pageserver_connstring GUC is set to the correct thing
execute("SELECT setting FROM pg_settings WHERE name='neon.pageserver_connstring'")