Skip to content

Commit c0d3b35

Browse files
authored
ffsync: Update syncstorage-rs to v0.21.1 (#6793)
* ffsync: Update syncstorage-rs to v0.21.1 * Apply fix for mariadb compatibility * Manually configure db socket for install and add on upgrade
1 parent ce7a378 commit c0d3b35

File tree

10 files changed

+148
-27
lines changed

10 files changed

+148
-27
lines changed

cross/diesel/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PKG_NAME = diesel
2-
PKG_VERS = 2.1.6
2+
PKG_VERS = 2.2.12
33
PKG_EXT = tar.gz
44
PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT)
55
PKG_DIST_SITE = https://github.com/diesel-rs/diesel/archive
@@ -23,12 +23,15 @@ CARGO_BUILD_ARGS += --features=mysql
2323
# we support MariaDB 10 only
2424
# we must define the mysql db socket, since the rust binaries (mysqlclient-sys)
2525
# do not read settings from bin/mysql_conf
26-
export "MYSQL_DB_SOCKET=/run/mysqld/mysqld10.sock"
26+
export MYSQL_DB_SOCKET=/run/mysqld/mysqld10.sock
2727

2828
# Point to MariaDB library and include directories
2929
ENV += MYSQLCLIENT_LIB_DIR=$(STAGING_INSTALL_PREFIX)/lib
3030
ENV += MYSQLCLIENT_INCLUDE_DIR=$(STAGING_INSTALL_PREFIX)/include/mariadb
3131

32+
# pass mysql client version for non-x86 archs
33+
ENV += MYSQLCLIENT_VERSION=$(lastword $(subst -, ,$(wildcard $(WORK_DIR)/mariadb-connector-c-[0-9]*)))
34+
3235
# let ./configure find mysql_config (it is a script and works for cross compile)
3336
ENV += "PATH=$(PATH):$(STAGING_INSTALL_PREFIX)/bin"
3437

cross/diesel/digests

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
diesel-2.1.6.tar.gz SHA1 ddb02dcb75dbfe03c8ab9cf905599390ae62d329
2-
diesel-2.1.6.tar.gz SHA256 60775915f615d41b65f31861ed01e467961677b7e430c6cc58d22c0b9bc17baf
3-
diesel-2.1.6.tar.gz MD5 294d6e5a841aaa4ec54ecf786f0e8993
1+
diesel-2.2.12.tar.gz SHA1 75ff812a934b333442a50fccc33a77e82e5268a8
2+
diesel-2.2.12.tar.gz SHA256 583f2d71a14b2bb318222474bd1f26f93e945a3e98dcf1b892c67463abe13897
3+
diesel-2.2.12.tar.gz MD5 000359985389abee7ceed4561ae52432

cross/syncstorage-rs/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PKG_NAME = syncstorage-rs
2-
PKG_VERS = 0.20.1
2+
PKG_VERS = 0.21.1
33
PKG_EXT = tar.gz
44
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
55
PKG_DIST_SITE = https://github.com/mozilla-services/$(PKG_NAME)/archive/${PKG_VERS}
@@ -33,6 +33,9 @@ ENV += MYSQLCLIENT_LIB_DIR=$(STAGING_INSTALL_PREFIX)/lib
3333
# to find dependencies of libmysqlclient (libz)
3434
ENV += RUSTFLAGS="-Clink-arg=-Wl,--rpath,$(INSTALL_PREFIX)/lib -Clink-arg=-Wl,--rpath-link,$(STAGING_INSTALL_PREFIX)/lib"
3535

36+
# pass mysql client version for non-x86 archs
37+
ENV += MYSQLCLIENT_VERSION=$(lastword $(subst -, ,$(wildcard $(WORK_DIR)/mariadb-connector-c-[0-9]*)))
38+
3639
POST_INSTALL_TARGET = syncstorage-rs_post_install
3740

3841
include ../../mk/spksrc.cross-rust.mk

cross/syncstorage-rs/digests

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
syncstorage-rs-0.20.1.tar.gz SHA1 2b58d7a1f951d54e4ba39012c0d3391c15ae94a0
2-
syncstorage-rs-0.20.1.tar.gz SHA256 4b5dc27d3b47fcd760301f084c1249777d53eb9db3d010c052a5ba539d3b9811
3-
syncstorage-rs-0.20.1.tar.gz MD5 7f3fed27e447f89bc8765d9b3f831266
1+
syncstorage-rs-0.21.1.tar.gz SHA1 c212b320af0374609e7e19b23638fa03ed739144
2+
syncstorage-rs-0.21.1.tar.gz SHA256 6ddcff79d62970df9d4fd6233ce79a4f92272c6582ced747de98ab24a1baba67
3+
syncstorage-rs-0.21.1.tar.gz MD5 0a71295bc9d3c770cb6fbb488ef43355
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
--- syncstorage-mysql/src/diesel_ext.rs 2025-09-23 16:12:34
2+
+++ syncstorage-mysql/src/diesel_ext.rs.new 2025-11-18 08:04:47
3+
@@ -3,11 +3,44 @@
4+
use diesel::{
5+
backend::Backend,
6+
insertable::CanInsertInSingleQuery,
7+
+ mysql::Mysql,
8+
query_builder::{AstPass, InsertStatement, QueryFragment, QueryId},
9+
+ query_dsl::methods::LockingDsl,
10+
result::QueryResult,
11+
Expression, QuerySource, RunQueryDsl,
12+
};
13+
14+
+/// Emit MySQL <= 5.7's `LOCK IN SHARE MODE`
15+
+///
16+
+/// MySQL 8 supports `FOR SHARE` as an alias (which diesel natively supports)
17+
+/// This is required for MariaDB which does not provide that alias.
18+
+pub trait LockInShareModeDsl {
19+
+ type Output;
20+
+
21+
+ fn lock_in_share_mode(self) -> Self::Output;
22+
+}
23+
+
24+
+impl<T> LockInShareModeDsl for T
25+
+where
26+
+ T: LockingDsl<LockInShareMode>,
27+
+{
28+
+ type Output = <T as LockingDsl<LockInShareMode>>::Output;
29+
+
30+
+ fn lock_in_share_mode(self) -> Self::Output {
31+
+ self.with_lock(LockInShareMode)
32+
+ }
33+
+}
34+
+
35+
+#[derive(Debug, Clone, Copy, QueryId)]
36+
+pub struct LockInShareMode;
37+
+
38+
+impl QueryFragment<Mysql> for LockInShareMode {
39+
+ fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Mysql>) -> QueryResult<()> {
40+
+ out.push_sql(" LOCK IN SHARE MODE");
41+
+ Ok(())
42+
+ }
43+
+}
44+
+
45+
#[allow(dead_code)] // Not really dead, Rust can't see it.
46+
#[derive(Debug, Clone)]
47+
pub struct OnDuplicateKeyUpdate<T, U, Op, Ret, DB, X>(
48+
--- syncstorage-mysql/src/models.rs 2025-09-23 16:12:34
49+
+++ syncstorage-mysql/src/models.rs.new 2025-11-18 08:07:49
50+
@@ -26,6 +26,7 @@
51+
use super::{
52+
batch,
53+
error::DbError,
54+
+ diesel_ext::LockInShareModeDsl,
55+
pool::CollectionCache,
56+
schema::{bso, collections, user_collections},
57+
DbResult,
58+
@@ -178,7 +179,7 @@
59+
.select(user_collections::modified)
60+
.filter(user_collections::user_id.eq(user_id))
61+
.filter(user_collections::collection_id.eq(collection_id))
62+
- .for_share()
63+
+ .lock_in_share_mode()
64+
.first(&mut *self.conn.write()?)
65+
.optional()?;
66+
if let Some(modified) = modified {

spk/ffsync/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SPK_NAME = ffsync
2-
SPK_VERS = 0.20.1
3-
SPK_REV = 8
2+
SPK_VERS = 0.21.1
3+
SPK_REV = 9
44
SPK_ICON = src/ffsync.png
55

66
DEPENDS = cross/syncstorage-rs cross/diesel
@@ -18,7 +18,7 @@ REQUIRED_MIN_SRM = 3.0
1818
MAINTAINER = SynoCommunity
1919
DESCRIPTION = An implementation of the Mozilla Sync-1.5 Server protocol used by the sync service in Firefox 29 and later. You can use Mozilla Sync Server to exchange browser data \(bookmarks, history, open tabs, passwords, add-ons, and the like\) between \'clients\' in a manner that respects a user\'s security and privacy. The service runs on port 8132.
2020
DISPLAY_NAME = Mozilla Sync Server
21-
CHANGELOG = "1. Update Mozilla Sync Server package to v0.20.1."
21+
CHANGELOG = "1. Update Mozilla Sync Server package to v0.21.1."
2222

2323
HOMEPAGE = https://mozilla-services.readthedocs.io/en/latest/howtos/run-sync-1.5.html
2424
LICENSE = MPL 2.0
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Generated using the requirements script on September 12, 2025
1+
# Generated using the requirements script on November 16, 2025
22

33
cffi==2.0.0
4-
charset_normalizer==3.4.3
5-
cryptography==44.0.2
4+
charset_normalizer==3.4.4
5+
cryptography==44.0.3
66
#greenlet ==> supported version depends on gcc version
77
mysqlclient==2.1.1
88
SQLAlchemy==1.4.46
9-
zope_interface==8.0
9+
zope_interface==8.1.1

spk/ffsync/src/requirements-pure.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Generated using the requirements script on September 12, 2025
1+
# Generated using the requirements script on November 16, 2025
22

33
backoff==2.2.1
44
boto==2.49.0
55
#certifi ==> python312
66
datadog==0.52.1
77
hawkauthlib==2.0.0
88
hupper==1.12.1
9-
idna==3.10
10-
iniconfig==2.1.0
9+
idna==3.11
10+
iniconfig==2.3.0
1111
packaging==25.0
1212
PasteDeploy==3.1.0
1313
#pip ==> python312
@@ -22,7 +22,7 @@ pyramid==1.10.8
2222
pytest==8.3.5
2323
requests==2.32.5
2424
#setuptools ==> python312
25-
testfixtures==9.1.0
25+
testfixtures==10.0.0
2626
tokenlib==2.0.0
2727
translationstring==1.4
2828
urllib3==2.5.0

spk/ffsync/src/service-setup.sh

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ SYNCSERVER="${SYNOPKG_PKGDEST}/bin/syncserver"
1313
DIESEL="${SYNOPKG_PKGDEST}/bin/diesel"
1414
CFG_FILE="${SYNOPKG_PKGVAR}/local.toml"
1515

16-
SERVICE_COMMAND="${SYNCSERVER} --config=${CFG_FILE}"
16+
# enhance logging
17+
ENV="RUST_LOG=debug RUST_BACKTRACE=full"
18+
19+
SERVICE_COMMAND="env ${ENV} ${SYNCSERVER} --config=${CFG_FILE}"
1720
SVC_BACKGROUND=y
1821
SVC_WRITE_PID=y
1922

20-
# enhance logging
21-
export RUST_LOG=debug
22-
export RUST_BACKTRACE=full
23-
2423
DBUSER=ffsync
2524
DBSERVER="localhost"
25+
DBSOCKET="/run/mysqld/mysqld10.sock"
2626

2727
percent_encode ()
2828
{
@@ -134,11 +134,60 @@ EOF
134134
-e "s|{{SQL_USER}}|${DBUSER}|g" \
135135
-e "s|{{SQL_PASS}}|${DBPASS_ENC}|g" \
136136
-e "s|{{DB_SERVER}}|${DBSERVER}|g" \
137+
-e "s|{{DB_SOCKET}}|${DBSOCKET}|g" \
137138
-e "s|{{METRICS_HASH_SECRET}}|${METRICS_HASH_SECRET}|g" \
138139
-i "${CFG_FILE}"
139140
fi
140141
}
141142

143+
service_postupgrade ()
144+
{
145+
# Verify socket suffix when upgrading existing configs
146+
if [ ! -f "${CFG_FILE}" ]; then
147+
return
148+
fi
149+
150+
echo "Verify database URLs for socket parameter"
151+
152+
sync_before=0
153+
token_before=0
154+
if grep -q '^syncstorage\.database_url[[:space:]]*=.*\?socket=' "${CFG_FILE}"; then
155+
sync_before=1
156+
fi
157+
if grep -q '^tokenserver\.database_url[[:space:]]*=.*\?socket=' "${CFG_FILE}"; then
158+
token_before=1
159+
fi
160+
161+
escaped_socket=$(printf '%s' "$DBSOCKET" | sed -e 's/[\/&|]/\\&/g')
162+
163+
sed -i \
164+
-e "/^syncstorage\.database_url[[:space:]]*=/ { /\?socket=/! s|\"$|?socket=${escaped_socket}\"| }" \
165+
-e "/^tokenserver\.database_url[[:space:]]*=/ { /\?socket=/! s|\"$|?socket=${escaped_socket}\"| }" \
166+
"${CFG_FILE}"
167+
168+
sync_after=0
169+
token_after=0
170+
if grep -q '^syncstorage\.database_url[[:space:]]*=.*\?socket=' "${CFG_FILE}"; then
171+
sync_after=1
172+
fi
173+
if grep -q '^tokenserver\.database_url[[:space:]]*=.*\?socket=' "${CFG_FILE}"; then
174+
token_after=1
175+
fi
176+
177+
if [ "$sync_before" -eq 0 ] && [ "$sync_after" -eq 1 ]; then
178+
echo "Added socket parameter to syncstorage.database_url"
179+
fi
180+
if [ "$token_before" -eq 0 ] && [ "$token_after" -eq 1 ]; then
181+
echo "Added socket parameter to tokenserver.database_url"
182+
fi
183+
184+
if [ "$sync_after" -eq 1 ] && [ "$token_after" -eq 1 ]; then
185+
echo "Database URLs now include socket parameter"
186+
else
187+
echo "Warning: unable to ensure socket parameter for both database URLs" >&2
188+
fi
189+
}
190+
142191
validate_preuninst ()
143192
{
144193
# Check database

spk/ffsync/src/var/local.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ host = "0.0.0.0"
88
# defined by SynoCommunity Package
99
port = {{TCP_PORT}}
1010

11-
syncstorage.database_url = "mysql://{{SQL_USER}}:{{SQL_PASS}}@{{DB_SERVER}}/syncstorage_rs"
11+
syncstorage.database_url = "mysql://{{SQL_USER}}:{{SQL_PASS}}@{{DB_SERVER}}/syncstorage_rs?socket={{DB_SOCKET}}"
1212
syncstorage.enable_quota = 0
1313
syncstorage.enabled = true
1414
syncstorage.limits.max_total_records = 1666 # See issues #298/#333
1515

1616
# token
17-
tokenserver.database_url = "mysql://{{SQL_USER}}:{{SQL_PASS}}@{{DB_SERVER}}/tokenserver_rs"
17+
tokenserver.database_url = "mysql://{{SQL_USER}}:{{SQL_PASS}}@{{DB_SERVER}}/tokenserver_rs?socket={{DB_SOCKET}}"
1818
tokenserver.enabled = true
1919
tokenserver.fxa_email_domain = "api.accounts.firefox.com"
2020
tokenserver.fxa_metrics_hash_secret = "{{METRICS_HASH_SECRET}}"

0 commit comments

Comments
 (0)